1var colors = ["red","blue","green"];
2for (var i = 0; i < colors.length; i++) {
3 console.log(colors[i]);
4}
1var colors = ['red', 'green', 'blue'];
2
3 colors.forEach((color, colorIndex) => {
4 console.log(colorIndex + ". " + color);
5 });
1var colors = ["red", "green", "blue"];
2for(var i = 0; i < colors.length; i++){
3 console.log(colors[i]);
4}
1var yearStart = 2000;
2var yearEnd = 2040;
3
4var arr = [];
5
6for (var i = yearStart; i < yearEnd+1; i++) {
7 arr.push(i);
8}
9
1const myArray = [6, 19, 20];const yourArray = [19, 81, 2];for (let i = 0; i < myArray.length; i++) { for (let j = 0; j < yourArray.length; j++) { if (myArray[i] === yourArray[j]) { console.log('Both loops have the number: ' + yourArray[j]) } }};