for loop
simple count-controlled loop
by dshilkret
JavaScript
/* example of a for loop
This example uses very common syntax for a count-controlled loop. The counter i goes from 0 to n-1, running the loop n times. Sometimes it's useful to know that after the looop i equals n.
*/
var n = 3;
for (var i = 0; i < n; i = i + 1) {
// useful code would go here
alert("i = " + i);
}
alert("after loop, i = " + i);