javascript array for i= code example
Example 1: loop array javascript
var colors = ['red', 'green', 'blue'];
colors.forEach((color, colorIndex) => {
console.log(colorIndex + ". " + color);
});
Example 2: javascript loop through array
const array1 = ['a', 'b', 'c'];
array1.forEach(element => console.log(element));