String.prototype.replaceintermediate'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.
Pass a regex as the first argument to match by pattern instead of literal string.
Challenge: Implement removeDigits(str) that removes all digits from a string using a regex with the g flag.
removeDigits('a1b2c3') // β 'abc'
removeDigits('hello') // β 'hello'