Last active
January 12, 2016 15:00
-
-
Save TravelingMan/3cf552b13474fd253ea8 to your computer and use it in GitHub Desktop.
Simple TitleCase
This file contains hidden or 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 workArr = str.split(" "); | |
for (var i = 0; i < workArr.length; i++) { | |
workArr[i] = workArr[i][0].toUpperCase() + workArr[i].substring(1).toLowerCase(); | |
} | |
return workArr.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