Last active
August 29, 2015 14:24
-
-
Save svahora/5d2947f4f7f0841f7bc8 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) { | |
str = str.toLowerCase().split(" "); | |
var word = []; | |
for(x=0; x<str.length; x++) { | |
var a = str[x].charAt(0).toUpperCase(); | |
var b = str[x].substr(1); | |
word.push(a + b); | |
} | |
str = word.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