Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. function journey(input) {
  2. let budget = Number(input.shift());
  3. let season = String(input.shift());
  4.  
  5. let campHotel = ``;
  6. let destination = ``;
  7. let spending = 0;
  8.  
  9. switch (season == `Summer`) {
  10. case true:
  11. campHotel = `Camp`;
  12. switch (budget <= 100) {
  13. case true:
  14. destination = `Bulgaria`;
  15. spending = budget * 0.3;
  16. break;
  17. case false:
  18. switch (budget > 100 && budget < 1000) {
  19. case true:
  20. destination = `Balkans`;
  21. spending = budget * 0.4;
  22. break;
  23. case false:
  24. destination = `Europe`;
  25. spending = budget * 0.9;
  26. }
  27. }
  28. break;
  29. case false:
  30. campHotel = `Hotel`;
  31. switch (budget <= 100) {
  32. case true:
  33. destination = `Bulgaria`;
  34. spending = budget * 0.7;
  35. break;
  36. case false:
  37. switch (budget > 100 && budget < 1000) {
  38. case true:
  39. destination = `Balkans`;
  40. spending = budget * 0.8;
  41. break;
  42. case false:
  43. destination = `Europe`;
  44. spending = budget * 0.9;
  45. }
  46. }
  47. }
  48. console.log(`Somewhere in ${destination}`);
  49. console.log(`${campHotel} - ${spending.toFixed(2)}`);
  50. }
  51.  
  52. journey([50, `Summer`]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement