Iteration

Resources:

Shiffman - 4.1 while and for Loops - p5.js
Shiffman - 4.2 Nested Loops - p5.js
p5 Examples: Iteration
p5 Examples: Embedded Iteration

for Loops

The for structure performs repetitive calculations and is structured like this:
for (init; test; update) {
      statements
}

For example, this loop draws vertical lines:

Write a for() loop that prints the following sequence of numbers to the console: 7, 10, 13, 16, 19, 22

Write a for() loop with a nested conditional statement that draws some lines on the left side of the canvas and some rectangles on the right side of the canvas.

Use a nested for() loop to create a 2D array of ellipses that change size along the y axis, and change color along the x axis.