Week5day3 Loops

For Loop: statement creates a loop with 3 optional expressions • While Loop: loops through a block of code as long as a specified condition is true. • Do While Loop: will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.

The For Loop The for statement creates a loop with 3 optional expressions:

for (expression 1; expression 2; expression 3) { }

Il code block to be executed Expression 1 is executed (one time) before the execution of the code block. Expression 2 defines the condition for executing the code block. Expression 3 is executed (every time) after the code block has been executed. Example

for (let i = 0; i < 5; i++) {
text += "The number is
+1 + "<br>";
}