Last active
November 22, 2015 23:40
-
-
Save dmidlo/2e0623a7a5ccc85ba5f0 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(); | |
var strArray = (str.split(' ')); | |
for(var i = 0; i < strArray.length; i++) | |
{ | |
strArray[i] = (strArray[i].charAt(0).toUpperCase()) + (strArray[i].substring(1)); | |
} | |
return(strArray.join(' ')); | |
} | |
titleCase("I'm a little tea pot shORt And Stout, HERE IS my HANDLE, HERe is My Spout!"); | |
// returns I'm A Little Tea Pot Short And Stout, Here Is My Handle, Here is My Spout!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment