Created
October 15, 2015 14:50
-
-
Save platypusrex/34c8dc8578e59c449836 to your computer and use it in GitHub Desktop.
Javascript - Title case any phrase
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) { | |
return str.split(' ').map(function(val){ | |
return val.charAt(0).toUpperCase() + val.slice(1).toLowerCase(); | |
}).join(' '); | |
} | |
titleCase("sHoRt AnD sToUt"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment