String.prototype.replaceAllintermediate'foo bar foo'.replaceAll('foo', 'baz') // β 'baz bar baz'
'banana'.replaceAll('a', 'o') // β 'bonono'Use replaceAll() to replace every occurrence of a search string or regex (with /g flag) with the replacement.
Replacing the empty string '' inserts the replacement between every character (like splitting).
Challenge: Implement joinCharsWithDash(str) that inserts a dash between every character.
joinCharsWithDash('abc') // β '-a-b-c-'