Advertisement
Spocoman

PastryShop

Feb 13th, 2022
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function pastryShop(input) {
  2.     let type = input[0];
  3.     let quantity = Number(input[1]);
  4.     let date = Number(input[2]);
  5.     let price = 0;
  6.  
  7.     if (date <= 15) {
  8.         if (type === "Cake") {
  9.             price = 24.0;
  10.         } else if (type === "Souffle") {
  11.             price = 6.66;
  12.         } else if (type === "Baklava") {
  13.             price = 12.60;
  14.         }
  15.     } else if (date > 15) {
  16.         if (type === "Cake") {
  17.             price = 28.7;
  18.         } else if (type === "Souffle") {
  19.             price = 9.8;
  20.         } else if (type === "Baklava") {
  21.             price = 16.98;
  22.         }
  23.     }
  24.     let sum = quantity * price;
  25.  
  26.     if (date <= 22 && sum >= 100 && sum <= 200) {
  27.         sum -= sum * 0.15;
  28.     } else if (date <= 22 && sum > 200) {
  29.         sum -= sum * 0.25;
  30.     }
  31.     if (date <= 15) {
  32.         sum -= sum * 0.1;
  33.     }
  34.     console.log(sum.toFixed(2))
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement