Tell us what’s happening:
I’m fine on the challenge.
I’m just still confused as to why the var version returns 3 for ```
console.log(printNumTwo())
If someone could send me a link that might explain this in a bit more detail that would be great.
var printNumTwo;
for (var i = 0; i < 3; i++) {
if (i === 2) {
printNumTwo = function() {
return i;
};
}
}
console.log(printNumTwo());
// returns 3
'use strict';
let printNumTwo;
for (let i = 0; i < 3; i++) {
if (i === 2) {
printNumTwo = function() {
return i;
};
}
}
console.log(printNumTwo());
// returns 2
console.log(i);
// returns "i is not defined"
Thanks,
Zak