Created
February 7, 2013 16:42
-
-
Save davetayls/4732246 to your computer and use it in GitHub Desktop.
String Extensions
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
/** | |
* Converts a string to Title case | |
* eg: hello how are you -> Hello How Are You | |
* @return {String} | |
*/ | |
String.prototype.toTitleCase = function(){ | |
return this.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