Assignment 020

For Loops

Another useful programming structure is the loop. JavaScript provides several ways to repeat commands easily. Let's start with the for loop. The following html was written with JavaScript:

The for loop requires three parameters:

The same three parameters are used, but with abbreviated coding. i=1 initializes the starting variable, and i++ adds 1 to the variable each time the loop runs (iteration).