Advertisement
DraconiusNX

Untitled

Sep 27th, 2022
54
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 quantity = Number(input[2]);
  5.     let totalPrice = 0;
  6.  
  7.     if(day == "Monday" || day == "Tuesday" || day == "Wednesday" || day == "Thursday" || day == "Friday") {
  8.         if(fruit == "banana") {
  9.             totalPrice = quantity * 2.50;
  10.         } else if(fruit == "apple") {
  11.             totalPrice = quantity * 1.20;
  12.         } else if(fruit == "orange") {
  13.             totalPrice = quantity * 0.85;
  14.         } else if (fruit == "grapefruit") {
  15.             totalPrice = quantity * 1.45;
  16.         } else if(fruit == "kiwi") {
  17.             totalPrice = quantity * 2.70;
  18.         } else if(fruit == "pineapple") {
  19.             totalPrice = quantity * 5.50;
  20.         } else if(fruit == "grapes") {
  21.             totalPrice = quantity * 3.85;
  22.         } else {
  23.             totalPrice = "error";
  24.         }
  25.     }
  26.     else if(day == "Saturday" || day == "Sunday") {
  27.         if(fruit == "banana") {
  28.             totalPrice = quantity * 2.70;
  29.         } else if(fruit == "apple") {
  30.             totalPrice = quantity * 1.25;
  31.         } else if(fruit == "orange") {
  32.             totalPrice = quantity * 0.90;
  33.         } else if(fruit == "grapefruit") {
  34.             totalPrice = quantity * 1.60;
  35.         } else if(fruit == "kiwi") {
  36.             totalPrice = quantity * 3.00;
  37.         } else if(fruit == "pineapple") {
  38.             totalPrice = quantity * 5.60;
  39.         } else if(fruit == "grapes") {
  40.             totalPrice = quantity * 4.20;
  41.         } else {
  42.             totalPrice = "error";
  43.         }
  44.     }
  45.     else {
  46.         totalPrice = "error";
  47.     }
  48.  
  49.     console.log(totalPrice);
  50. }
  51.  
  52. fruitShop(["tomato","Monday","0.5"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement