remove whitespace javascript

JavaScript
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();yourvariable.trim()
Source

Also in JavaScript: