Counting with a for Loop
Count from one number to another.
Counting with a for Loop is a free Javascript for Kids lesson on CoddyKit. This is 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, and your progress syncs across the web and the CoddyKit app. The Javascript for Kids course includes 4 lessons in total.
Counting with for 🔢
Hi, counting captain! 🌟 The for loop is great for counting!
It can count 1, 2, 3 all by itself. 🪄
for (let i = 1; i <= 3; i++) {
console.log(i)
}The Three Parts 🧩
A for loop has three parts inside ( ):
- Start: where to begin
- Rule: when to keep going
- Step: how to count up
for (let i = 0; i < 3; i++) {
console.log("Step!")
}The Counter i 🔢
The i is our counter. It remembers what number we are on!
It starts at 1 here and goes up. ⬆️
for (let i = 1; i <= 5; i++) {
console.log("Count: " + i)
}Counting Up ⬆️
i++ means "add one to i" each turn.
So i goes 1, 2, 3, 4... up and up! 🪜
for (let i = 1; i <= 4; i++) {
console.log(i)
}When to Stop 🛑
The rule i <= 5 means "keep going while i is 5 or less".
When i gets too big, the loop stops! 🚦
for (let i = 1; i <= 5; i++) {
console.log("Number " + i)
}Counting Candy 🍬
Let us count candies one by one!
Each loop counts one more candy. 😋
for (let i = 1; i <= 5; i++) {
console.log("Candy " + i + " 🍬")
}Start From Zero 0️⃣
Computers often start counting at 0!
i = 0; i < 3 gives 0, 1, 2. That is 3 turns! 🔢
for (let i = 0; i < 3; i++) {
console.log(i)
}Counting Rockets 🚀
Let us count up to launch!
1, 2, 3, GO! 🚀
for (let i = 1; i <= 3; i++) {
console.log(i + "...")
}
console.log("Blast off! 🚀")Bigger Counts 🔟
Want to count to 10? Just change the rule number!
The loop does all the work. 💪
for (let i = 1; i <= 10; i++) {
console.log(i)
}Counting Animals 🐑
Let us count sheep to fall asleep!
One sheep, two sheep... 😴
for (let i = 1; i <= 5; i++) {
console.log(i + " sheep 🐑")
}Your Counting Loop 🧒
Change the start and stop numbers to count YOUR way!
Count to your age! 🎂
for (let i = 1; i <= 7; i++) {
console.log("Number " + i)
}Quick Check ✅
Counting question! You got this! 🔢
Counting Captain! 🏆
Awesome! 🎉 Today you learned:
- A
forloop has Start, Rule, and Step iis the counteri++counts up by one
You are a counting captain! ⭐
for (let i = 1; i <= 1; i++) {
console.log("I can count with loops! 🎉")
}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 “Counting with a for Loop” lesson free?
Yes — the full text of “Counting with a for Loop” 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 “Counting with a for Loop”?
Count from one number to another. 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 2 of 4.
How long does the “Counting with a for Loop” 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
- Why We Use Loops
- Counting with a for Loop
- Repeating with while
- Drawing Patterns with Loops