vikkktor

fruitShop

May 24th, 2021 (edited)
74
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fruitShop(input) {
  2.     let product = input[0];
  3.     let day = input[1];
  4.     let quantity = Number(input[2]);
  5.  
  6.     if (day === "Monday" || day === "Tuesday" || day === "Wednesday" || day === "Thursday" || day === "Friday") {
  7.         switch (product) {
  8.             case "banana": console.log((quantity * 2.50).toFixed(2)); break;
  9.             case "apple": console.log((quantity * 1.20).toFixed(2)); break;
  10.             case "orange": console.log((quantity * 0.85).toFixed(2)); break;
  11.             case "grapefruit": console.log((quantity * 1.45).toFixed(2)); break;
  12.             case "kiwi": console.log((quantity * 2.70).toFixed(2)); break;
  13.             case "pineapple": console.log((quantity * 5.50).toFixed(2)); break;
  14.             case "grapes": console.log((quantity * 3.85).toFixed(2)); break;
  15.             default: console.log("error"); break;
  16.         }
  17.     } else if (day === "Saturday" || day === "Sunday") {
  18.         switch (product) {
  19.             case "banana": console.log((quantity * 2.70).toFixed(2)); break;
  20.             case "apple": console.log((quantity * 1.25).toFixed(2)); break;
  21.             case "orange": console.log((quantity * 0.90).toFixed(2)); break;
  22.             case "grapefruit": console.log((quantity * 1.60).toFixed(2)); break;
  23.             case "kiwi": console.log((quantity * 3.00).toFixed(2)); break;
  24.             case "pineapple": console.log((quantity * 5.60).toFixed(2)); break;
  25.             case "grapes": console.log((quantity * 4.20).toFixed(2)); break;
  26.             default: console.log("error"); break;
  27.         }
  28.     } else {
  29.         console.log("error");
  30.     }
  31. }
  32.  
  33. fruitShop(["apple",
  34. "Tuesday",
  35. "2"])
RAW Paste Data