The Classic for Loop
Count and repeat with an index.
Why Loops Exist
When you need to repeat work many times, copying code is painful. A loop runs the same block again and again so you write it just once. 🔁
Meet the for Loop
The classic for loop repeats a block a known number of times, using a counter you control from start to finish.
for (var i = 0; i < 3; i++) {
print('Hello');
}All lessons in this course
- The Classic for Loop
- while and do-while Loops
- for-in Over Collections
- break, continue, and Labels