Asking in Order
Loop through them.
Asking in Order 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.
One at a Time, Please! 🔁
A quiz show asks questions ONE BY ONE, in order. We use a loop to do that automatically! Let us learn how. 🎤
What is a Loop? 🌀
A loop repeats code so we do not have to type it over and over. Lazy in a smart way! 😎
for (let i = 0; i < 3; i++) {
console.log("Round " + i)
}Looping a List 📋
Loop through every question in the quiz list, one at a time.
let quiz = ["Q1?", "Q2?", "Q3?"]
for (let i = 0; i < quiz.length; i++) {
console.log(quiz[i])
}Numbering the Questions 1️⃣2️⃣3️⃣
Players love knowing which question they are on! Add a number.
let quiz = ["Sky color?", "Grass color?"]
for (let i = 0; i < quiz.length; i++) {
console.log("Question " + (i + 1) + ": " + quiz[i])
}Asking Object Questions 📦
Our questions are objects, so read the .question part inside the loop.
let quiz = [
{ question: "Sky color?", answer: "blue" },
{ question: "Snow color?", answer: "white" }
]
for (let i = 0; i < quiz.length; i++) {
console.log(quiz[i].question)
}A Friendlier Loop: forEach 🤝
forEach is an easy loop that visits each item. Super tidy!
let quiz = ["What is 1+1?", "What is 2+2?"]
quiz.forEach(function(q) {
console.log(q)
})forEach with a Number 🔢
forEach can also give you the position! Handy for numbering.
let quiz = ["A?", "B?"]
quiz.forEach(function(q, i) {
console.log((i + 1) + ") " + q)
})Showing Options Too 📋
For each question, also show its choices. A loop inside a loop! 🌀🌀
let q = { question: "Says moo?", options: ["dog", "cow"] }
console.log(q.question)
q.options.forEach(function(opt, i) {
console.log((i + 1) + ". " + opt)
})A Pause Between Questions ⏸️
In a real show, the host pauses. We can print a little break message!
let quiz = ["Q1?", "Q2?"]
quiz.forEach(function(q) {
console.log(q)
console.log("--- next question ---")
})The Last Question 🏁
Tell players when they reach the final question. Builds excitement!
let quiz = ["A?", "B?", "C?"]
for (let i = 0; i < quiz.length; i++) {
if (i === quiz.length - 1) {
console.log("FINAL: " + quiz[i])
} else {
console.log(quiz[i])
}
}Questions Flow in Order! ✅
Now your quiz asks every question in order, all by itself. The show runs smoothly! 🎬
let quiz = [
{ question: "1+1?" },
{ question: "2+2?" }
]
quiz.forEach(function(item, i) {
console.log("Q" + (i + 1) + ": " + item.question)
})Quick Check ❓
Loop-de-loop brain check! 🌀
Loop Hero! 🦸
Recap! You learned:
- 🌀 The
forloop - 🤝 The friendly
forEach - 1️⃣ Numbering questions
- 🏁 Spotting the last question
Next: keeping score! 🏆
Frequently asked questions
Is the “Asking in Order” lesson free?
Yes — the full text of “Asking in Order” 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 “Asking in Order”?
Loop through them. 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 “Asking in Order” 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
- Quiz Questions
- Asking in Order
- Scoring
- The Final Score