how to remove space in a string javascript code example
Example 1: remove spaces in a string js
str.replace(/\s+/g, '')
Example 2: js remove space from string
string.split(" ").join("")
Example 3: remove all spaces from a string javascript
.replace(/ /g,'')
Example 4: js remove space before string
var str = " Some text ";
str.trim();
// str = "Some text"
Example 5: remove space from string javascript
var puzzle1=myTrim($("#puzzleinput").val());
function myTrim(x) {
return x.replace(/^\s+|\s+$/gm,'');
}