ProdanTenev

Journey

Feb 15th, 2022 (edited)
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 1.00 KB | None | 0 0
  1. function journey(input) {
  2.     let budget = Number(input[0]);
  3.     let season = input[1];
  4.     // "summer" or "winter"
  5.     let totalSum;
  6.     let destination;
  7.     let vacationType;
  8.     if (budget <= 100) {
  9.         destination = "Bulgaria";
  10.         if (season == "summer") {
  11.             vacationType = "Camp";
  12.             totalSum = budget * 0.70;
  13.         } else {
  14.             vacationType = "Hotel";
  15.             totalSum = budget * 0.30;
  16.         }
  17.     } else if (budget > 1000){
  18.         destination = "Europe";
  19.         vacationType = "Hotel";
  20.         totalSum = budget * 0.1;        
  21.     } else {
  22.         destination = "Balkans";
  23.         if (season == "summer") {
  24.             vacationType = "Camp";
  25.             totalSum = budget * 0.6;
  26.         } else {
  27.             vacationType = "Hotel";
  28.             totalSum = budget * 0.2;
  29.         }
  30.     }
  31.     let money_left = budget - totalSum;
  32.     console.log(`Somewhere in ${destination}`);
  33.     console.log(`${vacationType} - ${money_left.toFixed(2)}`);
  34. }
Add Comment
Please, Sign In to add comment