Assessment wanted for Loops tasks

Hello! Need assessment for Loops skill tests.

Codepen:

I modified task two a little bit.

In a task three I thought for a long time why code dont work with:

Realized that loop is going to the next iteration before i-- and becomes infinite. :sweat_smile:

One question. There is link on article about best way to write For loop in a russian version of Looping code lesson. And one of the examples from comments is (codepen):
image

How does JS interpreter know that i must be >= 0?

Welcome back, @VladimirK :wave:

All your task are correct. I like the additional work you put in (variations, input form) and that you paid attention to the details like leaving out the comma a the end of task 3.

i-- is at the position where we normally have a condition that checks if a value is true (continue the loop) or false (exit the loop).

  • When i = 1 the condition is true (because 1 == true) and the value gets reduced to 0 (because of --)
  • Loop runs with i = 0
  • Now with i = 0 the condition is false (because 0 == false) and the loop exits

Iā€™m not really a fan of this version since the double use of the middle part as condition and value changer makes it confusion :woozy_face:

Have a nice day,
Michael

1 Like

Thank you for the review and explanations!

1 Like