11 lines
264 B
JavaScript
11 lines
264 B
JavaScript
function Accumulator(startingValue){
|
|
this.value = startingValue;
|
|
this.read = function(){
|
|
new_value = +prompt("value?", 0);
|
|
this.value += new_value;
|
|
}
|
|
}
|
|
|
|
let accumulator = new Accumulator(1);
|
|
accumulator.read();
|
|
alert(accumulator.value); |