Advertisement
Guest User

Untitled

a guest
Oct 5th, 2020
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function shop(arg1, arg2, arg3) {
  2.  
  3.     let day = arg2;
  4.     let fruit = arg1;
  5.     let quant = Number(arg3);
  6.     let price = 0;
  7.     let error = false;
  8.  
  9.     if (day === "Monday" || day === "Tuesday" || day === "Wednesday" || day === "Thursday" || day === "Friday") {
  10.  
  11.         switch (fruit) {
  12.  
  13.             case "banana": price = quant * 2.5; break;
  14.             case "apple": price = quant * 1.2; break;
  15.             case "orange": price = quant * 0.85; break;
  16.             case "grapefruit": price = quant * 1.45; break;
  17.             case "kiwi": price = quant * 2.7; break;
  18.             case "pineapple": price = quant * 5.5; break;
  19.             case "grapes": price = quant * 3.85; break;
  20.             default: error = true; console.log("error"); break;
  21.  
  22.  
  23.         }
  24.         if (!error) {
  25.             console.log(price.toFixed(2))
  26.         }
  27.     } else if (day === "Saturday" || day === "Sunday") {
  28.  
  29.         switch (fruit) {
  30.  
  31.             case "banana": price = quant * 2.7; break;
  32.             case "apple": price = quant * 1.25; break;
  33.             case "orange": price = quant * 0.9; break;
  34.             case "grapefruit": price = quant * 1.6; break;
  35.             case "kiwi": price = quant * 3; break;
  36.             case "pineapple": price = quant * 5.6; break;
  37.             case "grapes": price = quant * 4.2; break;
  38.             default: error = true; console.log("error"); break;
  39.  
  40.         }
  41.         if (!error) {
  42.             console.log(price.toFixed(2));
  43.         }
  44.     } else {
  45.         console.log("error")
  46.     }
  47. }
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement