en.javascript.info/01-js/06-objects-more/01-object-methods/07-calculator/solution.md
Ilya Kantor f301cb744d init
2014-10-26 22:10:13 +03:00

316 B

//+ run demo
var calculator = {
  sum: function() {
    return this.a + this.b;
  },

  mul: function() {
    return this.a * this.b;
  },

  read: function() {
    this.a = +prompt('a?', 0);
    this.b = +prompt('b?', 0);
  }
}

calculator.read();
alert( calculator.sum() );
alert( calculator.mul() );