Q:

js remove spaces

str.replace(/\s+/g, '')
6
string.split(" ").join("")
0
const removeSpaces = str => str.replace(/\s/g, '');

// Example
removeSpaces('hel lo wor ld');      // 'helloworld'
1
str = str.replace(/\s/g, '');
0
var str = "       Hello World!        ";
alert(str.trim());
5
str = str.trim();
1
var puzzle1=myTrim($("#puzzleinput").val());
            function myTrim(x) {
              return x.replace(/^\s+|\s+$/gm,'');
            }
0
var a = b = " /var/www/site/Brand new   document.docx ";

console.log( a.split(' ').join('') );
console.log( b.replace( /\s/g, '') ); 
0

New to Communities?

Join the community