Congratulations, you made it to the end of the course! You can now port the decision-making logic in Nadia’s booking confirmation script for the Millbrook Community Center. That means choosing rooms, preserving a waived deposit, filling in contact details, and deciding which bookings need a call before confirmation.
The aim is to keep each booking’s meaning as the script moves from Python to JavaScript. A blank phone field needs a fallback, while a zero deposit is a real answer. In this course, you learned how to:
- Read
&&and||as operators that select operand values, with short-circuiting that skips an unneeded right side. - Give an empty rooms array a default by checking
.length, rather than relying on its truthiness. - Choose
||for a blank phone field and??for a deposit that can legitimately be zero. - Fill in request fields with
??=,||=, and&&=, according to which values should trigger the assignment. - Port Python’s
matchguards to anelse ifchain and its mapping and sequence patterns to aswitchon a property with explicit checks. - Call a function from a lookup with
?.()and use??to provide a notice when the call’s result is nullish. The course’s handlers return strings, so a missing handler triggers the default.
Those choices let you express the center’s booking rules in JavaScript without losing the distinctions the Python script depends on.