Skip to content

Instantly share code, notes, and snippets.

@19h47
Last active June 15, 2017 11:40
Show Gist options
  • Save 19h47/4ec31ca574bea8455b9a07e7ac10f983 to your computer and use it in GitHub Desktop.
Save 19h47/4ec31ca574bea8455b9a07e7ac10f983 to your computer and use it in GitHub Desktop.
Return first letter for each word in a given string
/**
* First letter in uppercase of each word of a given string
*/
function UppercasefirstLetterString(str) {
var arr = str.toLowerCase().split(' ');
return arr.map( function(letter) {
return letter[0].toUpperCase() + letter.slice(1);
}).join(' ');
}
// used
UppercasefirstLetterString("I'm a little tea pot");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment