Javascript String ucfirstAll()

Description

Javascript String ucfirstAll()

/**/*from w  w  w  .ja va  2 s . c om*/
 * Uppercase the first character of each word in a string
 *
 *   `hello world` --> `Hello World`
 *
 * @return {string}
 */
String.prototype.ucwords = function ucfirstAll() {
  return this.split(' ').map(function(word) {
    return word.ucfirst();
  }).join(' ');
};



PreviousNext

Related