BeginnerCoder

Lesson 7 — Loops

Loops

A for loop repeats a block a set number of times. You control it with three parts: where to start, how long to keep going, and how to step — for (let i = 0; i < 5; i++).

Why it matters: loops automate repetition, from counting to processing every item in an array.

Tip: to print even numbers, step by 2 (i += 2) or check i % 2 === 0 inside the loop.

Want it another way?
Task

Change the loop so it logs the even numbers 2, 4, 6, 8, 10 — one per line.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.