1var colors=["red","blue","green"];
2for (let i = 0; i < colors.length; i++) {
3 console.log(colors[i]);
4}
1let str = "";
2
3for (let i = 0; i < 9; i++) {
4 str = str + i;
5}
6
7console.log(str);
8// expected output: "012345678"
9
1let str = '';
2
3for (let i = 0; i < 9; i++) {
4 str = str + i;
5}
6
7console.log(str);
8// expected output: "012345678"
9
1let panier = ['fraise', 'banane', 'poire'];
2
3for (const fruit in panier) {
4 console.log(panier[fruit]);
5}
1let items = ['beef', 'cabbage', 'javascript']; // Defines a list of items
2for (let item of items) { // Defines for loop with a variable of 'item'
3 console.log(item); // Prints the item that is found
4}