replace all letter in string javascript code example
Example 1: how to replace all characters in a string javascript
const string = "a, b, c, d, e, f";
string.replace(/,/g, '');
console.log(string) //a b c d e f
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);