The for loop in JavaScript
For Loop
Loops can execute a block of code multiple times. They are useful when we want to run the same code repeatedly, adding a different value each time. JavaScript has many different types of loops. Today we will discuss only the for loop.
Syntax of for loop is:-
for (statement 1; statement 2; statement 3) {
code block to be executed
}
Further Explanation:-
In this, statement 1 will be executed before the loop starts, and statement 2 defines code conditions for running code, statement 3 executes after every successful loop.
If statement 2 returns false, then the loop will not further proceed and the loop will end.