Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String.prototype.capitalize = function(capitalizeAll){
- if(capitalizeAll){
- return this.split(' ').map(function(e){return e.capitalize();}).join(' ');
- }else{
- return this.charAt(0).toUpperCase() + this.slice(1);
- }
- };
- "captitalize all words".capitalize(true); ==> "Captitalize All Words"
- "capitalize just first word".capitalize(); ==> "Capitalize just first word"
- Author: http://stackoverflow.com/a/20292655/703244
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement