to title javascript code example
Example 1: string to title case javascript
function titleCase(sentence) {
let sentence = string.toLowerCase().split(" ");
for (let i = 0; i < sentence.length; i++) {
sentence[i] = sentence[i][0].toUpperCase() + sentence[i].slice(1);
}
return sentence.join(" ");
}
Example 2: snentence case capitalisation js
const string = "tHIS STRING'S CAPITALISATION WILL BE FIXED."
const string = string.charAt(0).toUpperCase() + string.slice(1)