Beginner · 15 XP
Fix Async Closure Loop Bug
The provided function is intended to create an array of timer callbacks that print indices 0 through 4. However, due to `var` function-scoping, every callback prints `5`. Fix the code so that each callback retains its respective loop index `0, 1, 2, 3, 4`.
Show Step-by-Step Hint
- • Consider the scoping difference between `var` and `let`.
- • In ES6, `let` creates a new binding for each loop iteration.
Type: Bug Fix
Runtime: JAVASCRIPT
JAVASCRIPT solutionCHALLENGE #2