Contents |
|
Switch | Breaks |
Loops are used to execute a block of code a number of times.
A for loop runs from a start value to an end value. It's usually used to loop through every value in an array.
Example:
A while loop is used when you don't know how many times the loop should run. It continues only if a condition is met.
Example:
A do...while loop is used when you don't know how many times the loop should run. It continues only if a condition is met. Unlike a while loop, it runs once before any conditions are tested.
Example:
Switch | Breaks |