DEV Community

Discussion on: JS Quiz

Collapse
 
norrova profile image
Norro valentin

Firstly we define a variable to 0.
We create a loop who start to 4 and stop to 7 because (i<8).
When i equal to 6 we continue to the next iteration i equal to 7.

Result :

  1. sum = 4
  2. sum = 9 (4+5)
  3. continue => (sum = 9)
  4. sum = 16 (9+7)

the page display 16.

note : In the loop, post-increment is unnecessary, use pre-increment