Hack Frontend Community

Hotel Booking Cost Calculation

AvitoMail.ru
You need to write a function bookingCalculate(nights, checkInDate) that calculates the cost of hotel accommodation. Conditions:
  • The function takes two arguments:
    • nights (required) — number of nights to stay.
    • checkInDate (optional) — check-in date. If not specified, the current date is used.
  • The accommodation cost depends on the day of the week:
    • Weekdays (Monday–Friday) — 1500 rub.
    • Weekends (Saturday and Sunday) — 2200 rub.

Examples:

Input 1: 1, new Date("2023-11-11")
Output 1: 2200
Input 2: 5, new Date("2023-11-06")
Output 2: 7500
Run your code to see results.