Advertisement
Guest User

Untitled

a guest
Dec 7th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. String.prototype.capitalize = function(capitalizeAll){
  2. if(capitalizeAll){
  3. return this.split(' ').map(function(e){return e.capitalize();}).join(' ');
  4. }else{
  5. return this.charAt(0).toUpperCase() + this.slice(1);
  6. }
  7. };
  8.  
  9. "captitalize all words".capitalize(true); ==> "Captitalize All Words"
  10. "capitalize just first word".capitalize(); ==> "Capitalize just first word"
  11.  
  12. Author: http://stackoverflow.com/a/20292655/703244
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement