TZinovieva

Add Bags

Jan 1st, 2023 (edited)
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function addBags(input) {
  2.     let over20Price = Number(input[0]);
  3.     let suitcaseWeight = Number(input[1]);
  4.     let daysToTrip = Number(input[2]);
  5.     let suitcasesNumber = Number(input[3]);
  6.  
  7.     price = 0;
  8.     if (suitcaseWeight < 10) {
  9.         price = over20Price * 0.20;
  10.     } else if (suitcaseWeight >= 10 && suitcaseWeight <= 20) {
  11.         price = over20Price * 0.50;
  12.     } else {
  13.         price = over20Price;
  14.     }
  15.  
  16.     if (daysToTrip < 7) {
  17.         price += price * 0.40;
  18.     } else if (daysToTrip >= 7 && daysToTrip <= 30) {
  19.         price += price * 0.15;
  20.     } else {
  21.         price += price * 0.10;
  22.     }
  23.     let totalPrice = price * suitcasesNumber;
  24.     console.log(`The total price of bags is: ${totalPrice.toFixed(2)} lv.`);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment