Looping

What is a JavaScript Loop?

There is often a need to repeat a sequence of statements, such as when processing all of the items in a list. Loops are a way to execute the statements in a block of code multiple times.

There are two types of loops:

entry controlled loops: check the test condition before entry to the loop. The code within the loop is only executed if the test condition is true. These include the for and while loops.

exit controlled loops: check the test condition after the statements have executed. The loop will not continue for another iteration unless the test condition is true. The do while loop is an exit controlled loop.

Last updated