en.javascript.info/1-js/4-object-basics/05-constructor-new/3-accumulator/solution.md
Ilya Kantor 4c531b5ae7 ok
2016-07-31 00:28:27 +03:00

312 B

function Accumulator(startingValue) {
  this.value = startingValue;

  this.read = function() {
    this.value += +prompt('Сколько добавлять будем?', 0);
  };

}

var accumulator = new Accumulator(1);
accumulator.read();
accumulator.read();
alert( accumulator.value );