js replace all words that start with code example
Example 1: js replace all spaces
var replaced = str.replace(/ /g, '_');
Example 2: replace all character in string javascript
let a = "How to search and replace a char in a string";
while (a.search(" ", ""))
{
a = a.replace(" ", "");
}
console.log(a);