im doing a exercise of bills, tips and total of the all.
const calcTip = function (bill) {
return bill >= 50 && bill <= 300 ? bill * 0.15 : bill * 0.2;
};
const billsArray = [22, 295, 176, 440, 37, 105, 10, 1100, 86, 52];
const tipsArray = [];
const totalsArray = [];
for (let i = 0; i <= billsArray.length; i++) {
const tip = calcTip(billsArray[i]);
tipsArray.push(tip);
totalsArray.push(tip + billsArray[i]);
}
console.log(billsArray, tipsArray, totalsArray);
It's all right but in the browser console said that last one is not a number? someone knows why? do i need to use float?