Is there only one counter variable or more in the for loop?

'use strict';
let printNumTwo;
for (let i = 0; i < 3; i++) {
  if (i === 2) {
    printNumTwo = function() {
      return i;

And this statement is there below above code.
strong text
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.
my question is are there three different i variables or just one which is assigned three different number i.e 0,1 and 2 one after another ???
I think only one variable i is created , right??
i do not know i might be interpreting the classroom statement incorrectly, say so if that is the case!

Link to the challenge:

Good question, you are correct in thinking only one variable is created. I can see how that wording in the challenge could be misleading.

While the variable i is only being declared for the block of code in the let loop (the code between the brackets), it is being reassigned on each iteration.

One way to verify this behavior is to try it with a const instead of a let. Since const variables cannot be reassigned it should throw an error.

1 Like

@Lucasl right! const will verify it.Thanks for this concept.They should modify this statement.It’s misleading. Thanks.