BeginnerCoder

Lesson 14 — Exponential backoff

Backoff with a ceiling

Doubling the wait forever gets silly: the 10th retry would wait almost two minutes. So real retry policies add a cap — a maximum wait. The wait is the doubled value or the cap, whichever is smaller — Math.min picks it; ** means "to the power of", so 2 ** 3 is 8.

Math.min(1000, 100 * 2 ** 4)   // 1000, not 1600

Why it matters: capped backoff keeps retries polite without making users wait minutes.

Want it another way?
Task

Compute wait as base * 2 ** a, capped at 1000 with Math.min, for 6 attempts.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.