Javascript Theory
Loops
Loops are used to executed a set of statements repeatedly until a particlar condition is satisfied.
Types of Loops
Loops are classified into two types:
- Entry controlled loop(for loop, while loop)
- Exit controlled loop(do-while)
- Do While Loop
For Loop

For Loop
It execute a sequence of statements multiple times. A for loop has three arguments, namely, Initialization, test-condition, and increment/decrement variable.
Syntax |
---|
for(initialization statement; test condition; increment/decrement statement) { //statement to be executed repeatedly } |
While Loop

While Loop
It is an entry-controlled loop. A loop is used for executing a block of statements repeatedly until a given condition returns false.
Syntax |
---|
initialization statement; while (test-condition) { //statements to be executed repeatedly increment/decrement statement } |
Do While Loop

Do-While Loop
Do While loop is considered to be a conditional statement completely similar to a normal While loop. The only difference is that in do while loop except that it tests the condition at the end of the loop body.
Syntax |
---|
initialization statement; do { //statements to be executed increment/decrement statement } while (test-condition) |
