Upper case all letter in a String - Node.js String

Node.js examples for String:Case

Description

Upper case all letter in a String

Demo Code

String.prototype.ucFirstAll = function () {
  var intString = this.substr(0,1).toUpperCase() + this.substr(1,this.length);
  for(var k=1; k < intString.length; k++)
  {//from  ww w  . ja v a 2 s  . co  m
    if(intString[k-1] == ' '){
       intString = intString.substr(0,k)+intString.substr(k,1).toUpperCase()+intString.substr(k+1,intString.length);
    }
  }
  return intString;
}

Related Tutorials