← HALL
Async Loop Var Scope Closure
MEDIUM
+250 XP REWARD
⏱ Limit: 10m
// MISSION BRIEFING //
ANOMALY DESCRIPTION
A timer dispatch function uses a loop with 'var' to capture indices into scheduled callback closures. Due to function-scoping of 'var', all callbacks capture the final loop value. Refactor to block-scoped 'let'.
SPECIFICATION SUITE
3 callbacks
Input: 3
Expected: [0, 1, 2]
5 callbacks
Input: 5
Expected: [0, 1, 2, 3, 4]
Single callback
[PROTECTED TEST]
Evaluation logic hidden to prevent hardcoding.
RADAR HINTS
Hint #1 (Click to decrypt)
Declare the counter variable with let instead of var.
STATIC ANALYSIS CONSOLE
Ready for dispatch
Press "VERIFY & SUBMIT" or Ctrl+Enter to evaluate your patch.