Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function skiTrip(input) {
- let days = Number(input.shift());
- let room = input.shift();
- let feedback = input.shift();
- let nights = days - 1;
- let reduction = 0;
- let price = 0;
- if (room == "room for one person") {
- price = nights * 18.00;
- } else if (room == "apartment") {
- if (nights < 10) {
- reduction = (nights * 25) * 0.3;
- price = (nights * 25) - reduction;
- } else if (nights < 15) {
- reduction = (nights * 25) * 0.35;
- price = (nights * 25.00) - reduction;
- } else if (nights > 15) {
- reduction = (nights * 25) * 0.50;
- price = (nights * 25) - reduction;
- }
- } else if (room = "president apartment") {
- if (nights < 10) {
- reduction = (nights * 35) * 0.10;
- price = (nights * 35) - reduction;
- } else if (nights < 15) {
- reduction = (nights * 35) * 0.15;
- price = (nights * 35) - reduction;
- } else if (nights > 15) {
- reduction = (nights * 35) * 0.20;
- price = (nights * 35) - reduction;
- }
- }
- if (feedback == "positive") {
- price = price + (price * 0.25);
- } else {
- price = price - (price * 0.10);
- }
- console.log(price.toFixed(2));
- }
- skiTrip([2, "apartment", "positive"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement