why do you need to loop and array in javascript code example
Example 1: loop an array in javascript
let array = ["loop", "this", "array"]; // input array variable
for (let i = 0; i < array.length; i++) { // iteration over input
console.log(array[i]); // logs the elements from the current input
}
Example 2: loop through javascript array
let colors = ['red', 'green', 'blue'];
for (const color of colors){
console.log(color);
}