Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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'
Source by masteringjs.io #
 
PREVIOUS NEXT
Tagged: #javascript #uppercase #letter #word
ADD COMMENT
Topic
Name
5+8 =