Nadia’s booking confirmations need a notice for the caretaker as well as staffing numbers. Parties and weddings need the music switched off on time. Classes and meetings need their rooms ready early, with the room named when there’s exactly one. Anything else needs a manual check.
The Python script expresses those choices as patterns inside match. You can keep its decisions in JavaScript by checking the event kind, the number of rooms, and the room itself. Start with the fields that determine the notice.
Check the Request’s Fields
Python’s mapping pattern matches the dictionary keys it names and ignores extra keys. The request can still contain its name, hours, and phone number. Nadia’s Python function uses an or-pattern to accept either event kind and a sequence pattern to recognize exactly one room:
def notice_for(r):
match r:
case {"kind": "wedding" | "party"}:
return "music off by 11 p.m."
case {"kind": "class" | "meeting", "rooms": [room]}:
return f"{room} set up 15 minutes early"
case {"kind": "class" | "meeting"}:
return "rooms set up 15 minutes early"
case {"kind": kind}:
return f"check the {kind} request by hand"