Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function movieDestination(input) {
- let budget = Number(input[0]);
- let destination = input[1];
- let season = input[2];
- let daysCount = Number(input[3]);
- let price = 0;
- let totalPrice = 0;
- switch (season) {
- case "Winter":
- switch (destination) {
- case "Dubai":
- price = 45000;
- break;
- case "Sofia":
- price = 17000;
- break;
- case "London":
- price = 24000;
- break;
- }
- break;
- case "Summer":
- switch (destination) {
- case "Dubai":
- price = 40000;
- break;
- case "Sofia":
- price = 12500;
- break;
- case "London":
- price = 20250;
- break;
- }
- break;
- }
- if (destination === "Dubai") {
- price = price * 0.70;
- } else if (destination === "Sofia") {
- price = price * 1.25;
- } else {
- price = price;
- }
- totalPrice = daysCount * price;
- if (budget >= totalPrice) {
- console.log(`The budget for the movie is enough! We have ${(budget - totalPrice).toFixed(2)} leva left!`);
- } else if (totalPrice > budget) {
- console.log(`The director needs ${(totalPrice - budget).toFixed(2)} leva more!`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement