Is there a way to change only the first letter to capital letters? For example, if there is John Smith, I want to change it to John Smith, but I don't know what to do.
javascript
function toTitleCase(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
Do it like this.
© 2024 OneMinuteCode. All rights reserved.