javascript setance case code example
Example 1: snentence case capitalisation js
const string = "tHIS STRING'S CAPITALISATION WILL BE FIXED."
const string = string.charAt(0).toUpperCase() + string.slice(1)
Example 2: javascript string proper case
function toTitleCase(str) {
return str.replace(
/\w\S*/g,
function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
}
);
}
// example
toTitleCase("the pains and gains of self study");
// "The Pains And Gains Of Self Study"