Removing commas in a string

Hey guys, i have a basic js question here… how can i remove commas in a string and replace them with a space.

let myString = 'hello,this,is,a,difficult,to,read,sentence';

let myString = 'hello,this,is,a,difficult,to,read,sentence';
myString.replace(/,/g," ");

The regular expression with g ensures that all of the commas are found and replaced.

Read more here: Mozilla

1 Like