JavaScript elimina todos los espacios en blanco
var spacesString= "Do I have spaces?";
var noSpacesString= myString.replace(/ /g,'');// "DoIhavespaces?"
Grepper
var spacesString= "Do I have spaces?";
var noSpacesString= myString.replace(/ /g,'');// "DoIhavespaces?"
const removeSpaces = str => str.replace(/\s/g, '');
// Example
removeSpaces('hel lo wor ld'); // 'helloworld'
var str = " Some text ";
str.trim();
// str = "Some text"
var str = " Some text ";
str.trim();
"hello world".replace(/\s/g, "");
yourvariable.trim()