0Pricing
Javascript for Kids · Lesson

Looping Through a List

Visit every item in your array.

Looping a List 🔁📋

Hi, list explorer! 🌟 What if we want to see EVERY item in a list?

We use a special loop called for-of! It visits each item. 🪄

let pets = ["cat", "dog", "fish"]
for (let pet of pets) {
  console.log(pet)
}

The for-of Loop 🚶

for (let item of list) walks through the list, one item at a time!

Each turn, item is the next thing in the list. 👣

let fruits = ["apple", "banana", "grape"]
for (let fruit of fruits) {
  console.log(fruit)
}

All lessons in this course

  1. What Is an Array?
  2. Getting Items by Number
  3. Adding and Removing Items
  4. Looping Through a List
← Back to Javascript for Kids