471639 (6) [Avatar] Offline
#1
When I place the code in Listing 17.9 in a file (REPL.js) in my project, then run it in REPL using .load REPL.js (as directed two paragraphs above the Listing), it doesn't work.

It looks like line 11 is a complete, valid line of JavaScript, so REPL executes it without going into multi-line mode. However, line 12 is not valid code all by itself, so I get INVALID REPL KEYWORD.

This seems really simple, but is there some way to get this to work in REPL? What am I missing here?
471639 (6) [Avatar] Offline
#2
I found what feels like a hack in a SO thread (second answer, https://stackoverflow.com/questions/29203892/how-to-write-multiple-lines-of-code-in-node-repl). I wrapped all of the code in:

if(1){ **Listing 17.9** }


It works, but feels icky.