Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fruitShop(fruit, day, quantity) {
- quantity = Number(quantity);
- let price = 0;
- if (day == "saturday" || day == "sunday") {
- if (fruit == "banana") price = 2.70;
- else if (fruit == "apple") price = 1.25;
- else if (fruit == "orange") price = 0.90;
- else if (fruit == "grapefruit") price = 1.60;
- else if (fruit == "kiwi") price = 3.00;
- else if (fruit == "pineapple") price = 5.60;
- else if (fruit == "grapes") price = 4.20;
- } else if (day == "monday" || day == "tuesday" || day == "wednesday" || day == "thursday" || day == "friday") {
- if (fruit == "banana") price = 2.50;
- if (fruit == "apple") price = 1.20;
- if (fruit == "orange") price = 0.85;
- if (fruit == "grapefruit") price = 1.45;
- if (fruit == "kiwi") price = 2.70;
- if (fruit == "pineapple") price = 5.50;
- if (fruit == "grapes") price = 3.85;
- } if (price > 0) {
- console.log(price * quantity.toFixed(2))
- } else {
- console.log("error")
- }
- }
- fruitShop("apple", "tuesday", "2")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement