Last active
July 12, 2016 00:19
-
-
Save morishjs/0eba6646d74fac081ecbbd2aa00f4bf4 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) { | |
var list = str.split(' '); | |
var newList = list.map(function(arg){ | |
var firstString = arg[0]; | |
var restString = arg.split(arg[0]).join(''); | |
firstString = firstString.toUpperCase(); | |
restString = restString.toLowerCase(); | |
return firstString + restString; | |
}); | |
str = newList.join(' '); | |
return str; | |
} | |
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