Counting with a for Loop
Count from one number to another.
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!")
}All lessons in this course
- Why We Use Loops
- Counting with a for Loop
- Repeating with while
- Drawing Patterns with Loops