Javascript String title()

Description

Javascript String title()


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

module.exports = String;/*w  ww .ja v a  2 s  .  c o  m*/

Javascript String title()

String.prototype.title = function() {
    return this.replace(/\w\S*/g, function(txt) {
        return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    });/* ww w  . j a  va 2s  .  com*/
};



PreviousNext

Related