Didart

Hotel Room

Apr 2nd, 2022
1,044
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function hotelRoom(input) {
  2.     let month = input[0];
  3.     let nights = Number(input[1]);
  4.  
  5.     let studioPrice = 0;
  6.     let apartmentPrice = 0;
  7.  
  8.     if (month === 'May' || month === 'October') {
  9.         studioPrice = 50;
  10.         apartmentPrice = 65;
  11.         if (nights > 14) {
  12.             studioPrice *= 0.70;
  13.             apartmentPrice *= 0.90;
  14.         } else if (nights > 7) {
  15.             studioPrice *= 0.95;
  16.         }
  17.     } else if (month === 'June' || month === 'September') {
  18.         studioPrice = 75.20;
  19.         apartmentPrice = 68.70;
  20.         if (nights > 14) {
  21.             studioPrice *= 0.80;
  22.             apartmentPrice *= 0.90;
  23.         }
  24.     } else if (month === 'July' || month === 'August') {
  25.         studioPrice = 76;
  26.         apartmentPrice = 77;
  27.         if (nights > 14) {
  28.             apartmentPrice *= 0.90;
  29.         }
  30.     }
  31.     console.log(`Apartment: ${(apartmentPrice * nights).toFixed(2)} lv.`);
  32.     console.log(`Studio: ${(studioPrice * nights).toFixed(2)} lv.`);
  33.  
  34. }
  35.  
  36. hotelRoom(["May", "15"])
Advertisement
Add Comment
Please, Sign In to add comment