js remove empty space from string code example
Example 1: js remove space from string
string.split(" ").join("")
Example 2: javascript remove space from string
const removeSpaces = str => str.replace(/\s/g, '');
removeSpaces('hel lo wor ld');
Example 3: js remove space before string
var str = " Some text ";
str.trim();
Example 4: remove space from string javascript
var puzzle1=myTrim($("#puzzleinput").val());
function myTrim(x) {
return x.replace(/^\s+|\s+$/gm,'');
}
Example 5: how to remove empty spaces befiore string js
const greeting = ' Hello world! ';
console.log(greeting);
console.log(greeting.trim());