I'm new to programming and struggling with this code.
I know that "let" is block scoped, but how does the setTimeout access the "i" variable when its outside its sccope. I would really appreciate if someone could explain the code to me step by step.
for (let i = 0; i < 10; i++) {
console.log(i);
setTimeout(function () {
console.log('the number is ' + i);
}, 1000);
}