Debugging in the Console

This is where the JavaScript console comes in handy, as we get to see what the program is actually doing. Once you open up the console, you’ll see an error message that eat is not defined.

images/console_for_fun_and_fixing/eat_is_not_defined.png

When the browser tried to run the bad JavaScript code, it realized there was a problem. In our program, we told the browser to run the eat function, but we never told the browser how to do that. Errors found when trying to run the code are called run-time errors.

We’ll talk more about functions in Chapter 5, Functions: Use and Use Again. For now, it’s enough to know that a function is a way to write code that can be run again and ...

Get 3D Game Programming for Kids now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.