function calculateTipAmount(bill) {
var tipPercent;
if (bill < 50 ) {
tipPercent = .20;
} else if (bill >= 50 && bill < 200){
tipPercent = .15;
} else {
tipPercent = .10;
}
return tipPercent * bill;
}
var bills = [124, 48, 268];
var tips = [calculateTipAmount(bills[0]),
calculateTipAmount(bills[1]),
calculateTipAmount(bills[2])];
var finalValues =[bills[0] + tips[0],
bills[1] + tips[1],
bills[2] + tips[2]];
console.log(tips, finalValues);
I am trying to format the result of 18.599999999999998 as $18.6 in the console. I attempted using .toFixed(2) but did not achieve the desired outcome.