String.prototype.replaceAll() not working

There is no replaceAll in JavaScript: the error console was probably reporting an error.

Instead, use the /g (“match globally”) modifier with a regular expression argument to replace:

const a = "::::::";
const replaced = a.replace(/:/g,"hi");
console.log(replaced);

Leave a Comment