en.javascript.info/1-js/04-object-basics/06-constructor-new/3-accumulator/solution.md
Ilya Kantor 20784e7f26 up
2017-02-19 01:41:36 +03:00

17 lines
280 B
Markdown

```js run demo
function Accumulator(startingValue) {
this.value = startingValue;
this.read = function() {
this.value += +prompt('How much to add?', 0);
};
}
let accumulator = new Accumulator(1);
accumulator.read();
accumulator.read();
alert(accumulator.value);
```