Chapter 4. Loops

LOOPS ALLOW US to repeat lines of code until a certain set of conditions are met. It’s another simple concept on the surface, but one that allows us to do a surprising amount of work.for

You’ll use for loops in situations where you’ll be running a loop for a known number of times, or iterations. (By “known,” I don’t mean that we, the brains between the keyboards and chairs, necessarily know how many times we’ll need to go through a loop in advance; I just mean that we’ll be looping through a known quantity.)

The syntax for a loop is a little tricky, since we’re packing a lot of information into just a few ...

Get JavaScript for Web Designers 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.