JSFiddle - React, Tailwind, and code Playground
JavaScript
function cap(str) {
return str.replace(/([a-z])/, function (match, value) {
return value.toUpperCase();
})
}
alert(cap('50newyork'));
alert(cap('paris84'));
alert(cap('london'));