0Pricing
Javascript for Kids · Lesson

Looping Through a List

Visit every item in your array.

Looping Through a List is a free Javascript for Kids lesson on CoddyKit — 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, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

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

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, and the Javascript for Kids course includes 4 lessons in total. 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.

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; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

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