1var i; //defines i
2for (i = 0; i < 5; i++) { //starts loop
3 console.log("The Number Is: " + i); //What ever you want
4}; //ends loop
5//Or:
6console.log("The Number Is: " + 0);
7console.log("The Number Is: " + 1);
8console.log("The Number Is: " + 2);
9console.log("The Number Is: " + 3);
10console.log("The Number Is: " + 4);
11//They do the same thing!
12//Hope I helped!
1//for ... of statement
2
3const array1 = ['a', 'b', 'c'];
4
5for (const element of array1) {
6 console.log(element);
7}
8
9// expected output: "a"
10// expected output: "b"
11// expected output: "c"
12
1let iterable = [10, 20, 30];
2
3for (let value of iterable) {
4 value += 1;
5 console.log(value);
6}
7// 11
8// 21
9// 31
10
1let panier = ['fraise', 'banane', 'poire'];
2
3for (const fruit of panier) {
4 // console.log(fruit);
5 console.log(panier.indexOf(fruit));
6}
1const array1 = ['a', 'b', 'c'];
2
3for (const element of array1) {
4 console.log(element);
5}
6
7// expected output: "a"
8// expected output: "b"
9// expected output: "c"
10