I went through all examples and I think I get it, until the last one. The explanations doesn’t make total sense to me:
iis not defined because it was not declared in the global scope. It is only declared within the for loop statement.
- Fair enough, I get that part
printNumTwo()returned the correct value because three different
ivariables with unique values (0, 1, and 2) were created by the
letkeyword within the loop statement.
- That I don’t get.
- Within the FOR loop, ‘i’ takes values 0 for first run, then 1, then 2, then 3 at which point the condition i < 3 is not verified and the loop finishes.
- printNumTwo is assigned a function that returns i when i = 2
- I don’t understand why the explanation says that 3 different ‘i’ with unique values (0,1 and 2) were created
Many thanks in advance for your feedback and keep up the good code! I love it but need to practice a lot mooore!