Javascript String toWordsCase()

Description

Javascript String toWordsCase()


String.prototype.toWordsCase = function() {
 var tokens = this.split(/[\s]+/);
 
 if (tokens.length > 0) {
  var newString = tokens[0].toFirstCase();
  
  for (i = 1, n = tokens.length; i < n; i++) {
   newString = newString.concat(' ', tokens[i].toFirstCase());
  }/*from  w  w w  . ja v a  2  s.co m*/
  
  return newString;
 }
 
 return this;
};



PreviousNext

Related