Answers for "make every word of a string capitaliced js"

30

javascript capitalize words

//Updated 
//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(); });
};
Posted by: Guest on December-12-2020
0

make random letter capital in string javascript

var string = "freeCodecamp";

function capitalizeFirstLetter(str) {
  return str.charAt(0).toUpperCase() + str.slice(1);
}

capitalizeFirstLetter(string); // Returns "FreeCodecamp"
Posted by: Guest on June-09-2020

Code answers related to "make every word of a string capitaliced js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language