I'm curious about the following code and why it is that replace is not replacing the second underscore in string2
. It was my assumption that replace is going character by character through the string looking to replace the given value with the new value, but that apparently is not exactly the case.
const string1 = "hello_world"
const string2 = "hello__world"
string1.replace('_', '-') // 'hello-world'
string2.replace('_', '-') // 'hello-_world'