RSRobince Studio

JavaScript Loops

A loop repeats code. A for loop runs a set number of times: it has a start, a condition and a step.

for (let i = 1; i <= 3; i++) {
  console.log(i)
}
Try it yourself

Loading editor…

i++ means "add one to i". Make sure the condition eventually becomes false, or the loop never ends.