Advertisement
gskorchev

skiTrip

Jan 28th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function skiTrip(input) {
  2.     let days = Number(input.shift());
  3.     let room = input.shift();
  4.     let feedback = input.shift();
  5.     let nights = days - 1;
  6.     let reduction = 0;
  7.  
  8.     let price = 0;
  9.     if (room == "room for one person") {
  10.         price = nights * 18.00;
  11.     } else if (room == "apartment") {
  12.         if (nights < 10) {
  13.             reduction = (nights * 25) * 0.3;
  14.             price = (nights * 25) - reduction;
  15.         } else if (nights < 15) {
  16.             reduction = (nights * 25) * 0.35;
  17.             price = (nights * 25.00) - reduction;
  18.         } else if (nights > 15) {
  19.             reduction = (nights * 25) * 0.50;
  20.             price = (nights * 25) - reduction;
  21.         }
  22.     } else if (room = "president apartment") {
  23.         if (nights < 10) {
  24.             reduction = (nights * 35) * 0.10;
  25.             price = (nights * 35) - reduction;
  26.         } else if (nights < 15) {
  27.             reduction = (nights * 35) * 0.15;
  28.             price = (nights * 35) - reduction;
  29.         } else if (nights > 15) {
  30.             reduction = (nights * 35) * 0.20;
  31.             price = (nights * 35) - reduction;
  32.         }
  33.     }
  34.     if (feedback == "positive") {
  35.         price = price + (price * 0.25);
  36.     } else {
  37.         price = price - (price * 0.10);
  38.     }
  39.     console.log(price.toFixed(2));
  40. }
  41. skiTrip([2, "apartment", "positive"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement