javascript-learner/4.5constructor/t3.js

11 lines
264 B
JavaScript
Raw Permalink Normal View History

2024-06-03 12:16:54 +02:00
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);