SyntaxFix
Write A Post
Hire A Developer
Questions
You need to add the "global" flag to your regex:
s.replace(new RegExp("[0-9]", "g"), "X")
or, perhaps prettier, using the built-in literal regexp syntax:
.replace(/[0-9]/g, "X")