Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function skiTrip(input) {
- let days = Number(input[0]);
- let roomType = input[1];
- let rating = input [2];
- let nights = days - 1;
- let price = 0;
- switch (roomType) {
- case "room for one person":
- price = nights * 18; break;
- case "apartment":
- price = nights * 25;
- if (nights < 10) {
- price = price * 0.70;
- } else if (nights >= 10 && nights < 15) {
- price = price * 0.65;
- } else {
- price = price * 0.50;
- }
- break;
- case "president apartment":
- price = nights * 35;
- if (nights < 10) {
- price = price * 0.90;
- } else if (nights >= 10 && nights < 15) {
- price = price * 0.85;
- } else {
- price = price * 0.80;
- }
- break;
- }
- if (rating === "positive") {
- price = price * 1.25;
- } else {
- price = price * 0.90;
- }
- console.log(price.toFixed(2));
- }
Advertisement
Add Comment
Please, Sign In to add comment