Advertisement
ggeorgiev88

hotelRoom

Nov 17th, 2022
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function hotelRoom(input) {
  2.     let mounth = input[0];
  3.     let numberOfNihths = Number(input[1]);
  4.     let studioPrice = 0
  5.     let appartamentPrice = 0
  6.  
  7.     if (mounth === "May" || mounth === "October") {
  8.         if (numberOfNihths >= 1 && numberOfNihths <= 7) {
  9.             studioPrice = 50
  10.             appartamentPrice = 65
  11.         }
  12.         if (numberOfNihths > 7 && numberOfNihths <= 14) {
  13.             studioPrice = 50 * 0.95
  14.             appartamentPrice = 65
  15.         }
  16.         if (numberOfNihths > 14) {
  17.             studioPrice = 50 * 0.7
  18.             appartamentPrice = 65 * 0.9
  19.         }
  20.  
  21.     }
  22.     if (mounth === "June" || mounth === "September") {
  23.         if (numberOfNihths >= 1 && numberOfNihths <= 14) {
  24.             studioPrice = 75.2
  25.             appartamentPrice = 68.7
  26.         }
  27.         if (numberOfNihths > 14) {
  28.             studioPrice = 75.2 * 0.8
  29.             appartamentPrice = 68.7 * 0.9
  30.         }
  31.  
  32.     }
  33.     if (mounth === "July" || mounth === "August") {
  34.         if (numberOfNihths >= 1 && numberOfNihths <= 14) {
  35.             studioPrice = 76
  36.             appartamentPrice = 77
  37.         }
  38.         if (numberOfNihths > 14) {
  39.             studioPrice = 76
  40.             appartamentPrice = 77 * 0.9
  41.         }
  42.     }
  43.  
  44.  
  45.     console.log(`Apartment: ${(appartamentPrice * numberOfNihths).toFixed(2)} lv.`)
  46.     console.log(`Studio: ${(studioPrice * numberOfNihths).toFixed(2)} lv.`)
  47. }
  48.  
  49.  
  50.  
  51. //hotelRoom(["May", "15"])
  52. //hotelRoom(["June","14"])
  53. hotelRoom(["August", "20"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement