Last active
June 15, 2017 11:40
-
-
Save 19h47/4ec31ca574bea8455b9a07e7ac10f983 to your computer and use it in GitHub Desktop.
Return first letter for each word in a given string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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