Congratulations, the gym’s front desk now runs in JavaScript! node front-desk.js prints the same seven lines as front_desk.py, from M-101 Ana Reyes: £18.00 to Checked in today: 4, with Learn to Boulder is full before L-102 Leo Park: £18.00.
In this course, you learned how to:
- Identify what a name refers to and when you can use it: a function declaration from the top of its scope, a
letorconstonce its line has run - Read old
varcode, whose variables belong to the whole function or module and readundefineduntil assigned, then switch toletorconstand rerun - Keep state in a factory, returning an arrow or an object of arrows such as
{ next, issued } - Make functions in a loop with
for (const wall of WALLS), which gives each pass its ownwall - Take any number of arguments with
...charges, spread an array into a call, and gather extra options with...extras - Pass callbacks, give an optional one a
() => {}default, and set timers withsetTimeout() - Build functions from functions: fix a rate once with
makeDiscount(0.2), fix an argument aswithShoeHire()does, and run steps in order withpipe()
Know Where the Python Analogies Stop
Lookup still runs outward from where the code is written, as in LEGB, with blocks as extra scopes. Closures still keep the enclosing call’s variables, and you still put constants first and calls last. Other analogies stop partway: