Utilizor
Contact Us

Looping Arrays

Iterating over array elements.

Looping Arrays

Loops are often used to iterate over the elements of an array.

const cars = ["BMW", "Volvo", "Saab", "Ford"]; for (let i = 0; i < cars.length; i++) { text += cars[i] + "
"; }

Example

const fruits = ["Apple", "Banana"];
for (let i = 0; i < fruits.length; i++) {
  console.log(fruits[i]);
}