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?
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?
string.replace
doesn't modify a string; it returns a new string. Try:
const replaced = string.replace("½","0.5");