Advertisement
teofarov13

Untitled

Oct 26th, 2021
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fruitShop(input) {
  2.     let fruit = input[0];
  3.     let day = input[1];
  4.     let count = Number(input[2]);
  5.     let total = 0
  6.  
  7.     switch (day) {
  8.         case "Monday":
  9.         case "Tuesday":
  10.         case "Wednesday":
  11.         case "Thursday":
  12.         case "Friday":
  13.  
  14.             switch (fruit) {
  15.                 case "banana": total = count * 2.50;
  16.                     break;
  17.                 case "apple": total = count * 1.20;
  18.                     break;
  19.                 case "orange": total = count * 0.85;
  20.                     break;
  21.                 case "grapefruit": total = count * 1.45;
  22.                     break;
  23.                 case "kiwi": total = count * 2.70;
  24.                     break;
  25.                 case "pineapple": total = count * 5.50;
  26.                     break;
  27.                 case "grapes": total = count * 3.85;
  28.                     break;
  29.             }break;
  30.         case "Saturday":
  31.         case "Sunday":
  32.             switch (fruit) {
  33.                 case "banana": total = count * 2.70;
  34.                     break;
  35.                 case "apple": total = count * 1.25;
  36.                     break;
  37.                 case "orange": total = count * 0.90;
  38.                     break;
  39.                 case "grapefruit": total = count * 1.60;
  40.                     break;
  41.                 case "kiwi": total = count * 3;
  42.                     break;
  43.                 case "pineapple": total = count * 5.60;
  44.                     break;
  45.                 case "grapes": total = count * 4.20;
  46.                     break;
  47.             }break;
  48.  
  49.     }
  50.     if (total == 0) {
  51.         console.log('error')
  52.     } else {
  53.         console.log((total).toFixed(2))
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement