← Practice
Async·hard 30 min 120 XP

Timeout Wrapper

Write withTimeout(promise, ms) that resolves/rejects with the original promise, or rejects with an Error if it takes longer than ms.

Examples

  • withTimeout(slowPromise, 100) rejects if slowPromise takes over 100ms

Constraints

  • Keep the required function name so the tests can find it
  • Return a value instead of only logging it
  • Do not mutate inputs unless the challenge asks you to
Timeout Wrapper · editor

Code runs in an isolated Web Worker with a 3-second timeout — no DOM access, and it can never hang the page.