javascript-learner/4.5constructor/t3.js
2024-06-03 12:16:54 +02:00

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);