course content

Course Content

Introduction to JavaScript


The for loop is the hardest loop to understand.

To create this loop, you should use the for keyword that takes 3 parameters:

  • Initialization is a step when a new counter used by the for loop is initialized (executed only once).
  • Condition is an expression that will be checked on each iteration of the loop, like in the while loop.
  • Increment or Decrement are the operations performed on the counter at the end of each loop iteration.


Iteration in loops refers to repeating a block of code a certain number of times or until a certain condition is met. Each time the block of code is executed, it is considered one iteration.

Look at the example:

To better understand how the loop works, it's helpful to refer to a diagram:

You can use the decrement for the for loop:

The counter in the for loop has a unique space, and you shouldn’t be worried about the counter name:

Also, you can use different expressions for Increment/Decrement operations:

Section 5.

Chapter 4