Uppercase first letter - Node.js String

Node.js examples for String:Case

Description

Uppercase first letter

Demo Code

String.prototype.ucfirst = function() {
  return this.charAt(0).toUpperCase() + this.slice(1);
}

String.prototype.capitalize = function() {
  sentence = this.split(' ');
  for(word in sentence) {
    sentence[word] = sentence[word].ucfirst();
  }//  w w w .j  a  v  a  2 s.c o  m
  return sentence.join(' ');
}

Related Tutorials