Почему значения элементов в массиве finalPay имеют значение NAN? Как добавить сумму элементов массивов billValues и allTips в массив finalPay?
var restaurantPays = {
billValues : [124, 48, 268, 180, 42],
allTips : [],
finalPay : [],
tipCalculator : function() {
for (var i = 0; i < this.billValues.length; i++) {
var percentage;
if (this.billValues[i] < 50) {
percentage = .2;
} else if (this.billValues[i] >= 50 && this.billValues[i] < 200) {
percentage = .15;
} else {
percentage = .1;
}
this.allTips[i] = this.billValues[i] * percentage;
}
},
finalPayCalc : function() {
for (var i = 0; i < this.billValues.length; i++) {
this.finalPay[i] = this.billValues[i] + this.allTips[i];
}
}
}
restaurantPays.finalPayCalc();
restaurantPays.tipCalculator();
console.log(restaurantPays);