Q:

snentence case capitalisation js

function toTitles(s){ return s.replace(/\w\S*/g, function(t) { return t.charAt(0).toUpperCase() + t.substr(1).toLowerCase(); }); }
var str = toTitles('abraham lincoln'); // Abraham Lincoln
1
const string = "tHIS STRING'S CAPITALISATION WILL BE FIXED."
const string = string.charAt(0).toUpperCase() + string.slice(1)
1
function convertToTitleCase(str) {
    return str.replace( /wS*/g, function(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); });
}
var sentence=convertToTitleCase("we took a short walk.");//"We Took A Short Walk."
-2

New to Communities?

Join the community