Created
January 18, 2015 14:00
-
-
Save dev0x10/5646f050467f6ebb2911 to your computer and use it in GitHub Desktop.
Javascript string to title case
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 toTitleCase(str) { | |
| return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment