I told him it will return 0-9 if we use let instead of var. He was not convinced since he was expecting IIFE. Since he knew only that
Anónimo
14 ago 2020
I guess the question was 'How do I add a delay in a JavaScript loop?'.
for (let i = 0; i < 5; i++) {
(function(j) {
setTimeout[function() {
console.log(1000 * j );
}, 1000 * j);
})(i);
};