Created
May 25, 2017 14:49
-
-
Save abehmiel/2dcd099985b434a738781d7a03d60f60 to your computer and use it in GitHub Desktop.
Title Case in JS
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 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