Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function journey(input) {
- let budget = Number(input[0]);
- let season = input[1];
- let price = 0;
- let destination = "";
- let campingOrHotel = "";
- switch (season) {
- case "summer":
- if (budget <= 100) {
- campingOrHotel = "Camp";
- destination = "Bulgaria";
- price = budget * 0.3;
- } else if (budget <= 1000) {
- campingOrHotel = "Camp";
- destination = "Balkans";
- price = budget * 0.4;
- } else {
- campingOrHotel = "Hotel";
- destination = "Europe";
- price = budget * 0.9;
- }
- break;
- case "winter":
- if (budget <= 100) {
- campingOrHotel = "Hotel";
- destination = "Bulgaria";
- price = budget * 0.7;
- } else if (budget <= 1000) {
- campingOrHotel = "Hotel";
- destination = "Balkans";
- price = budget * 0.8;
- } else {
- campingOrHotel = "Hotel";
- destination = "Europe";
- price = budget * 0.9;
- }
- break;
- }
- console.log(`Somewhere in ${destination}`);
- console.log(`${campingOrHotel} - ${price.toFixed(2)}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment