0 points

capitalize string javascript - Google Search


dashboard

Sun Nov 08 2020 11:27:42 GMT+0000 (UTC)

Posted by @ali_alaraby #javascript

//capitalize only the first letter of the string. 
function capitalizeFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}
//capitalize all words of a string. 
function capitalizeWords(string) {
    return string.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
};
content_copy Copy

https://www.google.com/search?q