Advertisement
Guest User

Untitled

a guest
Sep 12th, 2022
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fruitShop([arg1, arg2, arg3]) {
  2.  
  3.     let fruit = arg1;
  4.  
  5.     let dayOfWeek = arg2;
  6.  
  7.     let quantity = Number(arg3);
  8.  
  9.     if (dayOfWeek == "Monday" || dayOfWeek == "Tuesday" || dayOfWeek == "Wednesday" || dayOfWeek == "Thursday" || dayOfWeek == "Friday") {
  10.  
  11.         if (fruit == "banana") {
  12.  
  13.             console.log((quantity * 2.5).toFixed(2));
  14.  
  15.         } else if (fruit == "apple") {
  16.  
  17.             console.log((quantity * 1.20).toFixed(2));
  18.  
  19.         } else if (fruit == "orange") {
  20.  
  21.             console.log((quantity * 0.85).toFixed(2));
  22.  
  23.         } else if (fruit == "grapefruit") {
  24.  
  25.             console.log((quantity * 1.45).toFixed(2));
  26.  
  27.         } else if (fruit == "kiwi") {
  28.  
  29.             console.log((quantity * 2.70).toFixed(2));
  30.  
  31.         } else if (fruit == "pineapple") {
  32.  
  33.             console.log((quantity * 5.5).toFixed(2));
  34.  
  35.         } else if (fruit == "grapes") {
  36.  
  37.             console.log((quantity * 3.85).toFixed(2));
  38.  
  39.         } else { //here
  40.             console.log("error");
  41.             return;
  42.         }
  43.  
  44.     } else if (dayOfWeek == "Sunday" || dayOfWeek == "Saturday") {
  45.  
  46.         if (fruit == "banana") {
  47.  
  48.             console.log((quantity * 2.7).toFixed(2));
  49.  
  50.         } else if (fruit == "apple") {
  51.  
  52.             console.log((quantity * 1.25).toFixed(2));
  53.  
  54.         } else if (fruit == "orange") {
  55.  
  56.             console.log((quantity * 0.90).toFixed(2));
  57.  
  58.         } else if (fruit == "grapefruit") {
  59.  
  60.             console.log((quantity * 1.60).toFixed(2));
  61.  
  62.         } else if (fruit == "kiwi") {
  63.  
  64.             console.log((quantity * 3).toFixed(2));
  65.  
  66.         } else if (fruit == "pineapple") {
  67.  
  68.             console.log((quantity * 5.60).toFixed(2));
  69.  
  70.         } else if (fruit == "grapes") {
  71.  
  72.             console.log((quantity * 4.20).toFixed(2));
  73.  
  74.         } else { //here
  75.             console.log("error");
  76.             return;
  77.         }
  78.  
  79.     } else {
  80.         console.log("error");
  81.         return;
  82.  
  83.     }
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement