js replace spaces in a variable code example
Example 1: js replace space
// replaces space with '_'
str = str.replace(/ /g, "_");
// or
str = str.split(' ').join('_');
Example 2: javascript string spaces replace with %20
string.replace()
// replaces space with '_'
str = str.replace(/ /g, "_");
// or
str = str.split(' ').join('_');
string.replace()