For Loop In JavaScript

Loris
Loris
Jul 10, 2017 · 1 min read

In JavaScript we have several condition loops: one of them is the for loop.

This type of loop is used when we want to run a loop for a certain number of times.

It is composed of 3 parts:

  1. “for” keyword: tell the JavaScript interpreter that the code that encounter after is a for loop.
  2. Condition: composed by 3 parts: initialization of the counter commonly called i or index; condition that make the loop run until it reaches a value of false; update of the counter variable.
  3. Code block: instructions that are executed if the condition is evaluated with a value of true.

That’s the very basic of the for loop in JavaScript.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade