String.prototype.replacebeginner'foo bar foo'.replace('foo', 'baz') // β 'baz bar foo'
'hello'.replace(/[aeiou]/g, '*') // β 'h*ll*'Use replace() to replace the first occurrence of a pattern; use a /g regex to replace all occurrences.
str.replace(searchValue, replaceValue) returns a new string with the first occurrence of searchValue replaced by replaceValue.
Challenge: Implement replaceFirst(str, from, to) that replaces the first occurrence of from with to.
replaceFirst('foo bar foo', 'foo', 'baz') // β 'baz bar foo'