The 130% Progress Bar — JavaScript Bug Hunt

Inspired by every upload dialog that has proudly announced "130%" or "NaN%".

  • Language: JavaScript
  • Layer: Frontend
  • Difficulty: Easy
  • Concepts: Math, Clamping
  • Modelled on: Upload dialogs
  • Visible tests: normal progress computes; over-completion clamps to 100; zero totals never NaN
  • Reward: 50 XP for a complete fix

Briefing

Inspired by every upload dialog that has proudly announced "130%" or "NaN%". Retried chunks push the done-count past the total, and empty uploads divide by zero.

progress.js renders the percentage. Clamp it into reality.

Bug report

BUG-130PCT · Reported by: design QA

percent(done, total):

  • an integer 0..100 (floor)
  • total 0 -> 0, never NaN
  • done beyond total -> 100, negatives -> 0

Observed: retries show 130%, empty folders show NaN%.

Logs

[upload] 13/10 chunks -> "130%"
[upload] 0/0 chunks -> "NaN%"

The code as shipped

src/ui/progress.js (editable)

// Renders upload progress as a whole percentage.
exports.percent = function (done, total) {
  return Math.floor((done / total) * 100);
};

Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More JavaScript bug hunts.