JSFiddle - React, Tailwind, and code Playground
by Beardy
JavaScript
var str = "hello you sexy beasts";
function eachWord(str){
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
function firstWord(str) {
return str.substr(0, 1).toUpperCase() + str.substr(1);
}
alert(eachWord(str));
alert(firstWord(str));