capital each letter of a word js code example
Example 1: javascript uppercase first letter of each word
const str = 'captain picard';
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
const caps = str.split(' ').map(capitalize).join(' ');
caps; // 'Captain Picard'
Example 2: capitalize first letter in array of strings javascript
for(var i = 1 ; i < newArr.length ; i++){
newArr[i].charAt(0).toUpperCase();