The For Loop part 1

The For Loop
33
1/3













Loops
Loops can execute a block of code a number of times. They are handy in cases in which you want to run the same code repeatedly, adding a different value each time.
JavaScript has three types of loops: for, while, and do while.
The for loop is commonly used when creating a loop.
The syntax:for (statement 1; statement 2; statement 3) {
code block to be executed
}
Statement 1 is executed before the loop (the code block) starts.
Statement 2 defines the condition for running the loop (the code block).
Statement 3 is executed each time after the loop (the code block) has been executed.
As you can see, the classic for loop has three components, or statements.
The classic "for" loop consists of how many components?
Comments
Post a Comment