PavelIvanov

Hotel Room

May 5th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function hotelRoom(month, countNights) {
  2.     countNights = Number(countNights);
  3.     let studioPrice = 0;
  4.     let apartment = 0;
  5.     if ((month === "May") || (month === "October")) {
  6.         studioPrice = 50 * countNights;
  7.         apartment = 65 * countNights;
  8.         if ((countNights > 7) && (countNights <= 14)) {
  9.             studioPrice *= 0.95;
  10.         } else if (countNights > 14) {
  11.             studioPrice *= 0.7;
  12.         }
  13.     }
  14.     if ((month === "June") || (month === "September ")) {
  15.         studioPrice = 75.2 * countNights;
  16.         apartment = 68.7 * countNights;
  17.         if (countNights > 14) {
  18.             studioPrice *= 0.8;
  19.         }
  20.     }
  21.     if ((month === "July") || (month === "August")) {
  22.         studioPrice = 76 * countNights;
  23.         apartment = 77 * countNights;
  24.     } if (countNights > 14) {
  25.         apartment *= 0.9;
  26.     }
  27.     console.log(`Apartment: ${apartment.toFixed(2)} lv.`);
  28.     console.log(`Studio: ${studioPrice.toFixed(2)} lv.`);
  29. }
Add Comment
Please, Sign In to add comment