JSFiddle - React, Tailwind, and code Playground

JavaScript

title = "1 New Messages";
for (var i=0; i < 10; i++) {
    regexp = /^(\d+)/
    
    if (numToReplace = title.match(regexp)) {
      title = title.replace(regexp, (parseInt(numToReplace[1])+1).toString())
    }
    document.write(title+'<br />');
}