JavaScript Loops Tutorial
In JavaScript, there are two different kind of loops:
- for - loops through a block of code a specified number of times
- while - loops through a block of code while a specified condition is true
Additionally, the JavaScript For ... In Statement loops through the elements of an array or through the properties of an object.
This tutorial demonstrates JavaScript methods to create a variety of JavaScript loops.
Pass Loops with += Assignment Operator
This is a demonstration of a pass loop, which writes from 20 to 1.
Odd and Even Loops - Modulus Operator
This script writes the odd and even numbers of each pass up to 10.
H1 to H6 Loop with + Arithmetic Operator
This script uses a for loop and the + operator to output mark-up for the H1 to H6 tags.