For Loops

Javascript Forloop

The For Loop is used to grab data, bit by bit (in layman’s terms)

 

This is a For Loop that just prints to screen the numbers 0 to 10:

Var i=0
for (i=0;i{
document.write (i+”
”);
}

To print/display on a webpage, all the names in a list you could use this code:

var i = 0;
var names = new Array();
names[i++] = ‘Roger’;
names[i++] = ‘Ryan’;
names[i++] = ‘Royce’;
document.write(‘Gracies
‘);
for (var j = 0; j ‘);
}

Leave a comment