Advertisement
DraconiusNX

Untitled

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