Viktomirova

AluminumJoinery

Feb 14th, 2022 (edited)
608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function aluminumJoinery(input) {
  2.   let countOrder = Number(input[0]);
  3.   let typeAl = input[1];
  4.   let delivery = input[2];
  5.   let deliveryPrice = 60;
  6.   let tempSum = 0;
  7.  
  8.   if (countOrder < 10) {
  9.     console.log(`Invalid order`);
  10.     return;
  11.   }
  12.   switch (typeAl) {
  13.     case "90X130":
  14.       tempSum = 110;
  15.       if (countOrder >= 30 && countOrder < 60) {
  16.         tempSum *= 0.95;
  17.       } else if (countOrder >= 60) {
  18.         tempSum *= 0.92;
  19.       }
  20.       break;
  21.     case "100X150":
  22.       tempSum = 140;
  23.       if (countOrder >= 40 && countOrder < 80) {
  24.         tempSum *= 0.94;
  25.       } else if (countOrder >= 80) {
  26.         tempSum *= 0.9;
  27.       }
  28.       break;
  29.     case "130X180":
  30.       tempSum = 190;
  31.       if (countOrder >= 20 && countOrder < 50) {
  32.         tempSum *= 0.93;
  33.       } else if (countOrder >= 50) {
  34.         tempSum *= 0.88;
  35.       }
  36.       break;
  37.     case "200X300":
  38.       tempSum = 250;
  39.       if (countOrder >= 25 && countOrder < 50) {
  40.         tempSum *= 0.91;
  41.       } else if (countOrder >= 50) {
  42.         tempSum *= 0.86;
  43.       }
  44.       break;
  45.   }
  46.  
  47.   let total = tempSum * countOrder;
  48.  
  49.   if (delivery === "With delivery") {
  50.     total += deliveryPrice;
  51.   }
  52.   if (countOrder > 99) {
  53.     total *= 0.96;
  54.   }
  55.   console.log(`${total.toFixed(2)} BGN`);
  56. }
Add Comment
Please, Sign In to add comment