Advertisement
vikkktor

hotelRoom

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