The For Loop part 1

JavaScript Tutorial
Conditionals and Loops
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: forwhile, 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?
4
2
1
3

Comments

Popular posts from this blog

Introducing object part 3

Comparison Operators part 2

Module 2