-2

my replace function only replace one character.

My Code example

const string = "What,Yo,Yes"
string.replace(","," ")

Console

"What Yo,Yes"

HamzahF
  • 19
  • 4

1 Answers1

0

Something like this:

const string = "What,Yo,Yes";
console.log(string.replace(/,/g," "));

Alternatively, you can use replaceAll, like this:

const string = "What,Yo,Yes"; 
console.log(string.replaceAll(","," "));
wakakak
  • 842
  • 5
  • 13