I have this code.
for (var i = 1; i <= 5; i++) {
setTimeout(function () {
console.log(i);
}, 1000);
}
I don't understand the output from this lines of code: The output in the console is number 6,and it says that is repeated five times. If i use the let keyword for "i" then i get the output that i expect, 1,2,3,4,5 after one second Why is that ?