Created
February 11, 2016 16:27
-
-
Save NEbere/248220d614a509730949 to your computer and use it in GitHub Desktop.
Return the provided string with the first letter of each word capitalized.
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
function titleCase(str) { | |
var strArray = str.toLowerCase().split(' '); | |
for (var i = 0; i < strArray.length; i++) { | |
strArray[i] = strArray[i][0].toUpperCase() + strArray[i].slice(1); | |
} | |
return strArray.join(' '); | |
} | |
titleCase("I'm a little tea pot"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment