loop methods javascript code example
Example 1: loop array javascript
var colors = ['red', 'green', 'blue'];
colors.forEach((color, colorIndex) => {
console.log(colorIndex + ". " + color);
});
Example 2: for loop
fruits = ['apple', 'orange', 'peach']
for fruit in fruits:
print(fruit)