for (var i = 0; i < 100; i++) {
console.log(i);
}
Expected output:
0
1
...
99
Commonly used to cache the length of an array.
var array = ['a', 'b', 'c'];
for (var i = 0; i < array.length; i++) {
console.log(array[i]);
}
Expected output:
'a'
'b'
'c'
for (var i = 0; i < 100; i += 2 /* Can also be: i = i + 2 */) {
console.log(i);
}
Expected output:
0
2
4
...
98
for (var i = 100; i >=0; i--) {
console.log(i);
}
Expected output:
100
99
98
...
0