var str = " Some text "; str.trim(); // str = "Some text"
string.split(" ").join("")
const removeSpaces = str => str.replace(/\s/g, ''); // Example removeSpaces('hel lo wor ld'); // 'helloworld'