how to uppercase first letter in an array in javascript code example
Example 1: javascript capitalize words
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function capitalizeWords(string) {
return string.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
};
Example 2: js capitalize first letter
var name = prompt("What is your name");
firstLetterUpper = name.slice(0,1).toUpperCase();
alert("Hello " + firstLetterUpper + name.slice(1, name.length).toLowerCase());