Congratulations, you made it to the end of the course! The bouldering gym’s front desk now runs in JavaScript as node front-desk.js. It 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 right before L-102 Leo Park: £18.00.
The port has no global, no nonlocal and no wall=wall. Each Python line kept its job and became what a JavaScript developer would write.
In this course, you learned how to:
- Say which variable a name refers to by following the scope chain outward from where the function is written, and when it can be used: a function declaration from the top of its scope, a
constorletvariable only once its line has run - Read old code that uses
var, whose variables belong to the whole function, or to the module at the top level, and start asundefined, and change it toletorconstwhen you touch it, then rerun it and check the output - Keep state in a closure, with a factory such as
makeBandCounter()that returns an arrow or an object of arrows over its own variables - Make functions in a loop with
for (const wall of WALLS), where each pass gets its ownwall - Take any number of arguments with a rest parameter such as
...charges, spread an array into a call, and gather extra options with...extras - Pass a callback, give an optional one a do-nothing default,
() => {}, and set a timer withsetTimeout() - Build functions from functions: an arrow that returns an arrow, an arrow that fixes an argument, and
pipe()to run steps in order