Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fruitShop(input) {
- let fruit = input[0];
- let day = input[1];
- let count = Number(input[2]);
- let total = 0
- switch (day) {
- case "Monday":
- case "Tuesday":
- case "Wednesday":
- case "Thursday":
- case "Friday":
- switch (fruit) {
- case "banana": total = count * 2.50;
- break;
- case "apple": total = count * 1.20;
- break;
- case "orange": total = count * 0.85;
- break;
- case "grapefruit": total = count * 1.45;
- break;
- case "kiwi": total = count * 2.70;
- break;
- case "pineapple": total = count * 5.50;
- break;
- case "grapes": total = count * 3.85;
- break;
- }break;
- case "Saturday":
- case "Sunday":
- switch (fruit) {
- case "banana": total = count * 2.70;
- break;
- case "apple": total = count * 1.25;
- break;
- case "orange": total = count * 0.90;
- break;
- case "grapefruit": total = count * 1.60;
- break;
- case "kiwi": total = count * 3;
- break;
- case "pineapple": total = count * 5.60;
- break;
- case "grapes": total = count * 4.20;
- break;
- }break;
- }
- if (total == 0) {
- console.log('error')
- } else {
- console.log((total).toFixed(2))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement