class Calculator {
#result = 0;
constructor() {
this.addition = this.addition.bind(this);
}
async dialog() {
const originalMsg = prompt('num: ');
const digitsMsg = originalMsg.replace(/\D/g, '');
return Number(digitsMsg);
}
addition(n) {
this.#result += n;
}
addDigit(n) {
if (typeof n === 'number') {
return this.addition(n);
}
this.dialog().then(this.addition);
}
result(callback) {
if (typeof callback === 'function') {
return callback(this.#result);
}
return this.#result;
}
clear() {
this.#result = 0;
}
}
Максимально декомпозировано и предусмотренно
let arr = []
let sum = 0
While (true) { *
let vod = prompt("num = ");
if (vod === ""
|| vod === null
|| vod === !isFinite(vod)) break;
arr.push(+vod);
}
for(let key of arr){
sum += key убери ошибку в коде
}
return sum
}
alert(snow())