All 35 Bugs /
0/35 Fixed ✓
JavaScriptMedium~10 min

Debounce Timer Reset Bug Firing Multiple Times

What's Broken (Symptom)

Declaring `let timerId` inside the returned inner function creates a fresh variable per keystroke, causing every single keypress to fire an API call.

Expected Behavior

  • • Hoist `let timerId` into the outer `createDebounced(fn, waitMs)` closure so repeated calls cancel the shared pending timer.

Debugging Hints (0/2 used)

Try spotting the bug in the editor first. Need a nudge? Reveal Hint 1 anytime.

Root Cause Breakdown

Pass all 1 automated verification checks on the right to unlock the full Root Cause explanation.

Automated Bug Verification

1 Checks Ready
  • Fires only once for rapid consecutive calls4 rapid calls resolve into 1 invocation with latest value.
bugfix.js
Live Sandboxed PreviewCtrl + Enter to verify
Console Output0 log(s)
No console output yet. Run Preview or Verify Bug Fix.