JavaScript Eliminar el primer espacio en la cadena

//use trim() on your string. It removes first and last whitepsaces

let str = " aa bb    ";
console.log(str.trim()); // "aa bb"
Amused Aardvark