ALSAVOV

Untitled

Jan 28th, 2023
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.34 KB | Source Code | 0 0
  1. function journey(input) {
  2.     let budget = Number(input[0]);
  3.     let season = input[1];
  4.  
  5.     let price = 0;
  6.     let destination = "";
  7.     let campingOrHotel = "";
  8.  
  9.     switch (season) {
  10.         case "summer":
  11.             if (budget <= 100) {
  12.                 campingOrHotel = "Camp";
  13.                 destination = "Bulgaria";
  14.                 price = budget * 0.3;
  15.             } else if (budget <= 1000) {
  16.                 campingOrHotel = "Camp";
  17.                 destination = "Balkans";
  18.                 price = budget * 0.4;
  19.             } else {
  20.                 campingOrHotel = "Hotel";
  21.                 destination = "Europe";
  22.                 price = budget * 0.9;
  23.             }
  24.             break;
  25.         case "winter":
  26.             if (budget <= 100) {
  27.                 campingOrHotel = "Hotel";
  28.                 destination = "Bulgaria";
  29.                 price = budget * 0.7;
  30.             } else if (budget <= 1000) {
  31.                 campingOrHotel = "Hotel";
  32.                 destination = "Balkans";
  33.                 price = budget * 0.8;
  34.             } else {
  35.                 campingOrHotel = "Hotel";
  36.                 destination = "Europe";
  37.                 price = budget * 0.9;
  38.             }
  39.             break;
  40.     }
  41.  
  42.     console.log(`Somewhere in ${destination}`);
  43.     console.log(`${campingOrHotel} - ${price.toFixed(2)}`);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment