const removeSpaces = str => str.replace(/\s/g, ''); // Example removeSpaces('hel lo wor ld'); // 'helloworld'
var str = " Hello World! "; alert(str.trim());