Timers, games and history · mid
Progress bars, queues and steppers
Progress-bar rounds escalate from one animated bar, to bars that run one after another, to at most N running at once (a concurrency-limited queue); steppers are the same idea for multi-step flows, with per-step validation and a clear current step.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- One bar: role='progressbar' with aria-valuenow/min/max (or native <progress>); animate with a CSS transition on transform: scaleX() or width.
- Queued bars: each 'Add' appends a bar; a bar starts only when the previous one finishes.
- Concurrency limit (e.g. 3): running count + a waiting queue; when one finishes, start the next — the same scheduler as a Promise task queue.
- Pause/resume: store progress and remaining duration; restart the transition from the stored value.
- Timing in React: drive progress with requestAnimationFrame or CSS transitions triggered by state; clean up timers per bar.
- Stepper/wizard: steps array, currentStep, completed set; Next validates the current step; Back keeps values; jump only to completed steps; aria-current='step'.
- Upload progress in real apps comes from XMLHttpRequest upload events (fetch has no upload progress), with a concurrency cap of 3–4.
The red pen
Common traps: mistake → fix
Mistake: Start all queued bars together
Fix: ignores the requirement.
Mistake: Track progress by counting setInterval ticks
Fix: drifts; compute from elapsed time.
Mistake: Let users jump to step 4 without finishing step 2
Fix: invalid submissions.
Easy to hard
Questions interviewers ask, easy to hard
- Build a progress bar that fills in 2 seconds after clicking Add.
- Each new bar waits for the previous one.
- Now at most 3 bars fill at the same time.
- Add pause and resume.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.