JavaScript question detail
How to convert a string to title case with javascript
Title case means that the first letter of each word is capitalized. You can convert a string to title case using the below function,
function toTitleCase(str) {
return str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();
});
}
toTitleCase("good morning john"); // Good Morning John