Loops
Loops
π¨βπΌ Let's practice a simple
for loop by building a numbered list.π¨ Open
and use a
for loop to build a string
with labels for exhibits 1 through 5. Each label should be on its own line.How a for loop works
for (let i = 0; i < limit; i++) {
// repeat work
}
Each part of the loop has a job:
- Initializer (
let i = 0) runs once before the loop starts - Condition (
i < limit) is checked before each iteration - Final expression (
i++) runs after each iteration
i++ means "add 1 to i." It's the same as i += 1.π MDN - for statement
π MDN - for...of (an alternative loop syntax you'll see in the wild)


