how to make loop in array on same element code example
Example 1: javascript loop through array
const myArray = ['foo', 'bar'];
myArray.forEach(x => console.log(x));
//or
for(let i = 0; i < myArray.length; i++) {
console.log(myArray[i]);
}
Example 2: loop through javascript array
let colors = ['red', 'green', 'blue'];
for (const color of colors){
console.log(color);
}