Repeating and Skipping Code with while and if

Normally JavaScript code is run from top to bottom. The lines of code at the top of a program are run first. Once the computer is done running those lines, it moves on to the next lines. This happens all the way to the bottom of a program file.

But sometimes we don’t want all of the code to run. And other times we want to run code more than once. For these times, we use control keywords. The keywords that we’ll see the most in this book are while and if.

Code in ICE, Check in the Console

images/callout-icons/tip.png

The code in the rest of this chapter is too large for the JavaScript console, so add it in ICE after the START CODING ...

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.