TZinovieva

Easter Trip

Dec 22nd, 2022
53
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 booking = input[1];
  4.     let nights = Number(input[2]);
  5.  
  6.     let price = 0;
  7.     switch (destination) {
  8.         case "France":
  9.             if (booking === "21-23") {
  10.                 price = 30 * nights;
  11.             } else if (booking === "24-27") {
  12.                 price = 35 * nights;
  13.             } else {
  14.                 price = 40 * nights;
  15.             }
  16.             break;
  17.         case "Italy":
  18.             if (booking === "21-23") {
  19.                 price = 28 * nights;
  20.             } else if (booking === "24-27") {
  21.                 price = 32 * nights;
  22.             } else {
  23.                 price = 39 * nights;
  24.             }
  25.             break;
  26.         case "Germany":
  27.             if (booking === "21-23") {
  28.                 price = 32 * nights;
  29.             } else if (booking === "24-27") {
  30.                 price = 37 * nights;
  31.             } else {
  32.                 price = 43 * nights;
  33.             }
  34.             break;
  35.     }
  36.     console.log(`Easter trip to ${destination} : ${price.toFixed(2)} leva.`);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment