Advertisement
Spocoman

Add Bags

Feb 16th, 2022
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function addBags(input) {
  2.     let priceOver20kg = Number(input[0]);
  3.     let bagWeight = Number(input[1]);
  4.     let dayBefore = Number(input[2]);
  5.     let bagCount = Number(input[3]);
  6.  
  7.     if (bagWeight < 10) {
  8.         priceOver20kg /= 5;
  9.     } else if (bagWeight <= 20) {
  10.         priceOver20kg /= 2;
  11.     }
  12.  
  13.     if (dayBefore < 7) {
  14.         priceOver20kg *= 1.4;
  15.     } else if (dayBefore <= 30) {
  16.         priceOver20kg *= 1.15;
  17.     } else if (dayBefore > 30) {
  18.         priceOver20kg *= 1.1;
  19.     }
  20.  
  21.     let total = priceOver20kg * bagCount;
  22.  
  23.     console.log(` The total price of bags is: ${total.toFixed(2)} lv. `);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement