how to convert to title case in js code example
Example 1: title case javascript
function titleCase(str) {
return str
.split(' ')
.map((word) => word[0].toUpperCase() + word.slice(1).toLowerCase())
.join(' ');
}
console.log(titleCase("I'm a little tea pot")); // I'm A Little tea Pot
Example 2: snentence case capitalisation js
const string = "tHIS STRING'S CAPITALISATION WILL BE FIXED."
const string = string.charAt(0).toUpperCase() + string.slice(1)