JS Built-ins
ControlFlowbeginner

Control Flow β€” for loop

for loop: counter-based iteration

The classic for loop gives you precise control: for (init; condition; update) { }.

Challenge: Write sumTo(n) that returns the sum 1+2+...+n using a for loop.

πŸ’‘ Hints (1)
  • β€’ i <= n means include n itself in the sum