Working on the below, when logging the array 'tips' it seems that the numbers pushed into it have only one decimal point.
Before adding in parseFloat it would return 2 decimal points, however it was returned as a string. Once parseFloat was added it now only seems to return a single decimal point.
Thank you.
var tips = [];
var calculateTip = function(bill) {
switch (true) {
case bill < 50:
tips.push(parseFloat((bill * 0.2).toFixed(2)));
break;
case bill >= 50 && bill < 201:
tips.push(parseFloat((bill * 0.15).toFixed(2)));
break;
default:
tips.push(parseFloat((bill * 0.10).toFixed(2)));
}
}
calculateTip(124);
calculateTip(48);
calculateTip(268);
console.log(tips);