Advertisement
Guest User

HotelRoom

a guest
Mar 2nd, 2018
287
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function hotelRoom([month, nights]) {
  2.     nights = Number(nights);
  3.     let priceStudio = 0;
  4.     let priceApartment = 0;
  5.    
  6.  
  7.  
  8.     if(month == 'May' || month == 'October') {
  9.         priceStudio = 50;
  10.         priceApartment = 65;
  11.         if(nights > 7 && nights <= 14) {
  12.             priceStudio = 50 - (50 * 0.05);
  13.        
  14.         } else if(nights > 14) {
  15.             priceStudio = 50 - (50 * 0.3);
  16.             priceApartment = 65 - (65 * 0.1); }
  17.  
  18.     } else if(month == 'June' || month == 'September') {
  19.         priceStudio = 75.2;
  20.         priceApartment = 68.70;
  21.         if(nights > 14) {
  22.             priceStudio = 75.2 - (75.2 * 0.2);
  23.             priceApartment = 68.70 - (68.70 * 0.1); }
  24.  
  25.     } else if(month == 'July' || month == 'August') {
  26.         priceStudio = 76;
  27.         priceApartment = 77;
  28.         if(nights > 14)
  29.            {priceStudio = 76;
  30.             priceApartment = 77 - (77 * 0.1);}
  31.  
  32.     }
  33.     let totalPriceStudio = (priceStudio * nights).toFixed(2);
  34.     let totalPriceApartment = (priceApartment * nights).toFixed(2)
  35.     console.log(`Apartment: ${totalPriceApartment} lv.
  36. Studio: ${totalPriceStudio} lv.`)
  37. }
Advertisement
RAW Paste Data Copied
Advertisement