const billCalculator = (price, tax = 0.13, tip) => {
if (price <= 20 && price >= 1) {
tip = 0.05;
} else if (price >= 21 && price <= 40) {
tip = 0.15;
} else if (price >= 41 && price <= 60) {
tip = 0.15;
} else if (price >= 61) {
tip = 0.25;
}
return price + (price * tax) + (price * tip);
};
const popup = prompt(`Your bill:`);
const call = billCalculator(popup);
console.log(call);
Here I wanted whatever the amount I put in the prompt is the argument for Price. But the return not adding up. Say if I put 100, I am getting 1001325 but it should be 138. What I am doing wrong here actually?