Javascript for Kids · Lesson

Looping Through a List

Visit every item in your array.

Lesson 4 of 413 steps

Looping Through a List is a free Javascript for Kids lesson on CoddyKit. This is lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Javascript for Kids learning path, and your progress syncs across the web and the CoddyKit app. The Javascript for Kids course includes 4 lessons in total.

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)
}

Visiting Every Treasure 💎

Let us visit every treasure in our chest and show it!

The loop grabs each one for us. 🤲

let treasure = ["gold", "gem", "crown"]
for (let item of treasure) {
  console.log("Found: " + item)
}

Looping Numbers 🔢

for-of works with number lists too!

Let us print every score. 🎮

let scores = [10, 20, 30]
for (let score of scores) {
  console.log(score)
}

Greeting Every Friend 👋

Let us say hi to every friend on the team!

The loop greets them all. 🤝

let team = ["Sam", "Lily", "Max"]
for (let name of team) {
  console.log("Hi, " + name + "!")
}

Adding Them Up ➕

We can use a loop to add all the numbers in a list!

Keep a total box and add each number. 🧮

let numbers = [1, 2, 3, 4]
let total = 0
for (let n of numbers) {
  total = total + n
}
console.log("Total: " + total)

Counting Items in a Loop 🔢

We can count how many treats we have by counting in a loop!

Add one for each item. 🍬

let treats = ["candy", "cookie", "cake"]
let count = 0
for (let t of treats) {
  count++
}
console.log("Treats: " + count)

Shouting Every Word 📢

Let us make every word in the list SHOUT!

Use toUpperCase on each one. 🔊

let words = ["hello", "hi", "yay"]
for (let w of words) {
  console.log(w.toUpperCase())
}

Decorating Each Item 🎨

We can add a fun emoji to every item in the loop!

Make each one sparkle. ✨

let animals = ["cat", "dog", "fish"]
for (let a of animals) {
  console.log(a + " ⭐")
}

Feeding Every Pet 🦴

Let us feed every pet on the list using a loop!

Nobody goes hungry. 🐶🐱🐠

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

Your Loop Adventure 🧒

Change the list items and loop through YOUR own list!

What will your loop show? 🎉

let myList = ["fun", "code", "yay"]
for (let item of myList) {
  console.log(item)
}

Quick Check ✅

Final question! You are a star! 🌟

List Explorer! 🏆

Incredible! 🎉 Today you learned:

  • for-of visits every item in a list
  • Each turn gives you the next item
  • You can add, shout, or count every item!

You finished Treasure Lists! You are a coding hero! 🦸⭐

let win = ["You", "are", "amazing!"]
for (let w of win) {
  console.log(w)
}
Free to start

Learn JavaScript with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
35
Lessons
140

Frequently Asked Questions

Is the “Looping Through a List” lesson free?

Yes — the full text of “Looping Through a List” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Javascript for Kids course, upgrade to CoddyKit PRO. The Javascript for Kids course includes 4 lessons in total.

What will I learn in “Looping Through a List”?

Visit every item in your array. You practise Javascript for Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Javascript for Kids?

No prior experience is required. Javascript for Kids on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 4 of 4.

How long does the “Looping Through a List” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Javascript for Kids lesson?

Yes. Every Javascript for Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

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