I'm trying to figure out why this for loop does not render out 0,1,2,3 like its suppose to.
It renders 4, 4 , 4, 4
.
How would i get this to print 0, 1, 2, 3
with the setTimeout still in place ?
for (var i = 0; i < 4; i++) {
setTimeout(function() {
console.log('The index of this number is: ' + i);
}, 3000);
}