Replace all instances of a substring without Regex in JavaScript