Class to Join letter to word - Node.js Object

Node.js examples for Object:Class Definition

Description

Class to Join letter to word

Demo Code


var Letters = function () {
  this.letters = [];/*from   w w  w  .j  a  va  2s. c  o m*/
};

Letters.prototype.push = function (letter) {
  this.letters.push(letter);
  return this;
};

Letters.prototype.toWord = function () {
  return this.letters.join('');
};

var l = new Letters();
l.push('H')
.push('e')
.push('l')
.push('l')
.push('o');

console.log(l.toWord());

Related Tutorials