Advertisement
Liliana797979

easter trip

Jan 25th, 2021
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function easterTrip(input) {
  2.     let destination = input[0];
  3.     let dates = input[1];
  4.     let nightsCount = Number(input[2]);
  5.     let totalPrice = 0;
  6.  
  7.     switch (destination) {
  8.         case "France":
  9.             switch (dates) {
  10.                 case "21-23":
  11.                 totalPrice = nightsCount * 30;
  12.                     break;
  13.                 case "24-27":
  14.                     totalPrice = nightsCount * 35;
  15.                     break;
  16.                 case "28-31":
  17.                     totalPrice = nightsCount * 40;
  18.                     break;
  19.             }
  20.         case "Italy":
  21.             switch (dates) {
  22.                 case "21-23":
  23.                 totalPrice = nightsCount * 28;
  24.                     break;
  25.                 case "24-27":
  26.                     totalPrice = nightsCount * 32;
  27.                     break;
  28.                 case "28-31":
  29.                     totalPrice = nightsCount * 39;
  30.                     break;
  31.             }
  32.         case "Germany":    
  33.         switch (dates) {
  34.             case "21-23":
  35.             totalPrice = nightsCount * 32;
  36.                 break;
  37.             case "24-27":
  38.                 totalPrice = nightsCount * 37;
  39.                 break;
  40.             case "28-31":
  41.                 totalPrice = nightsCount * 43;
  42.                 break;
  43.         }
  44.             break;
  45.     }
  46.  
  47.     console.log(`Easter trip to ${destination} : ${(totalPrice).toFixed(2)} leva.`);
  48. }
  49.  
  50. easterTrip(["Italy", "21-23", "7"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement