Created
November 18, 2015 19:29
-
-
Save IAmAnubhavSaini/3da677ed44378b7261cb to your computer and use it in GitHub Desktop.
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) { | |
return str.split(' ').map(String.toLowerCase).map(function(a){ return String.toUpperCase(a[0]).concat(a.substring(1));} ).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
str.split(' ').map(function(a){ return String.toUpperCase(a[0]).concat(a.slice(1).toLowerCase());} ).join(' ')
Thanks @ljharb