Brief Aside: Semicolons
Did you notice the semicolon (;
) at the end of the commands from the last
challenge?
In JavaScript, every statement ends with a semicolon. It tells the JavaScript
engine that the command is complete.
In the REPL, you can run the command without the semicolon and it'll work just
fine. Try!
So far, the REPL is only reading a single command at a time, so there's never
any ambiguity. Even when we're running entire programs, it's usually safe
to exclude the semicolon. In fact, some developers make a point of leaving them out.
But you'll see lots of them and many tools that help fix your code will add them
if you haven't, so it's good to know why they're there.
And now you know. Click ✓.