A standard while loop will execute until the condition given is false:
var i = 0;
while (i < 100) {
console.log(i);
i++;
}
Expected output:
0
1
...
99
var i = 100;
while (i > 0) {
console.log(i);
i--; /* equivalent to i=i-1 */
}
Expected output:
100
99
98
...
1
A do...while loop will always execute at least once, regardless of whether the condition is true or false:
var i = 101;
do {
console.log(i);
} while (i < 100);
Expected output:
101