0Pricing
Javascript for Kids · Lesson

Getting Items by Number

Pick items using their position.

Getting Items by Number is a free Javascript for Kids lesson on CoddyKit — lesson 2 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.

Grabbing Treasures 🤲

Hi, treasure grabber! 🌟 How do we get ONE item out of a list?

We use its position number inside [ ]! 🔢

let treasure = ["gold", "gem", "crown"]
console.log(treasure[0])

Counting Starts at Zero! 0️⃣

Surprise! Lists count from 0, not 1!

The first item is at position [0]. 🤯

let pets = ["cat", "dog", "fish"]
console.log(pets[0])

The Second Item 1️⃣

The second item is at position [1]!

0 is first, 1 is second. A little tricky but fun! 🎈

let pets = ["cat", "dog", "fish"]
console.log(pets[1])

The Third Item 2️⃣

The third item is at position [2].

See the pattern? Position is always one less than the count! 🪄

let pets = ["cat", "dog", "fish"]
console.log(pets[2])

Grabbing Gold 🪙

Let us grab the first treasure from our chest!

Position 0 is the gold. 🪙

let treasure = ["gold", "gem", "crown"]
console.log("I found: " + treasure[0])

Pick Your Favorite 💖

Use the position number to pick any item you want!

Change the number to grab a different one. 🎯

let snacks = ["candy", "cookie", "cake"]
console.log(snacks[2])

Numbers in a List 🔢

We grab numbers from a list the same way!

Position 0 gets the first number. 🧮

let scores = [10, 20, 30]
console.log(scores[1])

Counting Friends 🧒

Let us say hi to the first friend in our team list!

Position 0 is the team captain. 👋

let team = ["Sam", "Lily", "Max"]
console.log("Captain: " + team[0])

Out of Range 🚫

If you ask for a position that does not exist, you get undefined!

That means "nothing there". Our list only goes to position 2 here. 🤷

let pets = ["cat", "dog", "fish"]
console.log(pets[5])

The Last Item 🏁

The last item is at position length - 1!

If there are 3 items, the last one is at position 2. 🎯

let colors = ["red", "blue", "green"]
console.log(colors[colors.length - 1])

Your Turn to Grab 🧒

Change the position number to grab different treasures!

Remember: counting starts at 0. 🔢

let chest = ["map", "key", "coin", "ring"]
console.log(chest[2])

Quick Check ✅

Position question! You can do it! 🎯

Treasure Grabber! 🏆

Awesome! 🎉 Today you learned:

  • Get an item with its position: list[0]
  • Counting starts at 0!
  • The last item is at length - 1

You are a treasure grabber! ⭐

let win = ["You", "did", "it!"]
console.log(win[2])

Frequently asked questions

Is the “Getting Items by Number” lesson free?

Yes — the full text of “Getting Items by Number” 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 “Getting Items by Number”?

Pick items using their position. 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 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Getting Items by Number” 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