Doubt in ES6: Compare Scopes of the var and let Keywords

I have doubt in the following statement from freecodecamp tutorial.

“printNumTwo() returned the correct value because three different I variables with unique values (0, 1, and 2) were created by the let keyword within the loop statement.”

if initializer part of for loop executes only once then in which part of for loop, the 3 separate “i” variable is being created?

please explain the same in details.


Because of the let, the behaviour is different. Javascript interpreter comes to the for loop each time and sees there is no variable in the scope so it resets the variable each time (not sure how it knows to which starting point but that must be a detail in the interpreter that knows this).