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.


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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.