vborislavova

06. Journey - Conditional Statements Advanced

Feb 24th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function journey(input) {
  2.   let bugdet = Number(input.shift());
  3.   let season = input.shift();
  4.  
  5.   let expense = 0;
  6.   let destination = 0;
  7.   let typeAccomm = 0;
  8.  
  9.   if (bugdet <= 100) {
  10.     destination = "Bulgaria";
  11.     switch(season) {
  12.       case "summer": expense = bugdet * 0.30; break;
  13.       case "winter": expense = bugdet * 0.70; break;
  14.     }
  15.   } else if (bugdet <= 1000) {
  16.     destination = "Balkans";
  17.     switch(season) {
  18.       case "summer": expense = bugdet * 0.40; break;
  19.       case "winter": expense = bugdet * 0.80; break;
  20.     }
  21.   } else {
  22.     destination = "Europe";
  23.     expense = bugdet * 0.90;
  24.   }
  25.  
  26.   if (season == "summer" && destination !== "Europe") {
  27.     typeAccomm = "Camp";
  28.   } else {
  29.     typeAccomm = "Hotel";
  30.   }
  31.  
  32.   console.log(`Somewhere in ${destination}`);
  33.   console.log(`${typeAccomm} - ${expense.toFixed(2)}`);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment