AniUI Academy
hard+350 XPPractice Available

Retry a request with backoff

A request that fails once will often succeed on the next try. Exponential backoff prevents hammering struggling APIs.

Implement retry(task, { attempts, baseDelay }). Retry on rejection until attempts run out, doubling the delay each time.

What it has to do

  • Resolve as soon as any attempt succeeds.
  • Reject with the last error once attempts are exhausted.
  • Double the delay after each failure, starting at baseDelay.

Your workspace

Try it yourself
Loading playground...

Ready to check it?

3 tests run against your code, right here in your browser. Sign in to claim the XP when you pass.

AI Crack & Solution Assist

Stuck? Get instant AI hints or break down the optimal solution.

Stuck? The javascript course covers everything this challenge needs.