1let array = ["foo", "bar"]
2
3let low = 0; // the index to start at
4let high = array.length; // can also be a number
5
6/* high can be a direct access too
7 the first part will be executed when the loop starts
8 for the first time
9 the second part ("i < high") is the condition
10 for it to loop over again.
11 the third part will be executen every time the code
12 block in the loop is closed.
13*/
14for(let i = low; i < high; i++) {
15 // the variable i is the index, which is
16 // the amount of times the loop has looped already
17 console.log(i);
18 console.log(array[i]);
19} // i will be incremented when this is hit.
20
21// output:
22/*
23 0
24 foo
25 1
26 bar
27*/
1let text = '';
2let zahl = 10;
3for ( let i=0; i<=zahl; i++ ) {
4 text = text + i + ' mal 3 ist ' + i*3 + '\n';
5}
6console.log (text);
7