2

I have a simple string like this, let string = "123½"; and I want to replace it.

I've already tried string.replace("½","0.5")

I'm not exactly what is happening here, but maybe it's because it's a special character?

j08691
  • 204,283
  • 31
  • 260
  • 272

1 Answers1

3

string.replace doesn't modify a string; it returns a new string. Try:

const replaced = string.replace("½","0.5");
Jacob
  • 77,566
  • 24
  • 149
  • 228