String prototype in
With this method, we can globally replace all matching patterns with a replacement in your string. It can handle patterns that are strings or a
Regex. Let’s look at some code!
const testString = 'The test dog is a test to replace all dog instances'. testString.replaceAll("dog", "chicken"); //output: // "The test chicken is a test to replace all chicken instances."