Async & Promises

Exponential Backoff Retry

hardJS SpecificJS / TS3 tests

Problem Statement

Implement `retryWithBackoff(fn, options)` where options include `retries`, `baseDelay`, and `factor`. On each failure, delay increases by `baseDelay * Math.pow(factor, attempt)`. The function rejects if all attempts are exhausted.

Examples

Example 1:
let calls = 0;
const fn = async () => {
  if (++calls < 3) throw new Error('Temporary failure');
  return 'ok';
};
await retryWithBackoff(fn, { retries: 3, baseDelay: 10, factor: 2 }); // 'ok'
JavaScript & TypeScript starter code included
Run this as a live interview

Practice solo

3 test cases. No second person needed.

Get new interview exercises

Practice problems and review drills, sent when we publish new ones. No spam.

Unsubscribe anytime. We never share your address.