js parse text string first letter capital and make others letter lowercase code example
Example 1: javascript first letter uppercase
const upperCase = function(names){
const toLower = names.toLowerCase().split(' ');
const namesUpper = [];
for(const wordName of toLower){
namesUpper.push(wordName[0].toUpperCase() + wordName.slice(1));
}
return namesUpper.join(' ');
}
Example 2: js capitalize word
const capitalizeFirstLetter(string) =>
string.charAt(0).toUpperCase() + string.slice(1).toLowerCase()