Advertisement
DraconiusNX

Untitled

Sep 12th, 2022
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function luggage(input) {
  2.  
  3.     var luggagePriceOver20kg = input[0];
  4.     var luggageWeight = input[1];
  5.     var daysBeforeFlight = input[2];
  6.     var luggageCount = input[3];
  7.     var luggagePrice = 0;
  8.  
  9.     if (luggageWeight < 10) {
  10.         var luggagePrice = luggagePriceOver20kg / 5;
  11.     }
  12.     else if (luggageWeight >= 10 && luggageWeight <= 20) {
  13.         var luggagePrice = luggagePriceOver20kg / 2;
  14.     } else {
  15.         var luggagePrice = luggagePriceOver20kg;
  16.     }
  17.  
  18.     if (daysBeforeFlight > 30) {
  19.         var newLuggagePrice = luggagePrice + ((luggagePrice / 100) * 10);
  20.     }
  21.     else if (daysBeforeFlight >= 7 && daysBeforeFlight <= 30) {
  22.         var newLuggagePrice = luggagePrice + ((luggagePrice / 100) * 15);
  23.     } else {
  24.         var newLuggagePrice = luggagePrice + ((luggagePrice / 100) * 40);
  25.     }
  26.  
  27.     var finalAmount = newLuggagePrice * luggageCount;
  28.  
  29.     console.log(`The total price of bags is: ${finalAmount.toFixed(2)} lv.`);
  30.  
  31. }
  32.  
  33. luggage([63.8,23,3,1]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement