Average Watch Time: Infinity — JavaScript Bug Hunt
Inspired by every analytics dashboard that has proudly displayed "Infinity minutes" or "NaN%" on launch day, before any traffic arrived.
- Language: JavaScript
- Layer: Frontend
- Difficulty: Easy
- Concepts: Math, Division
- Modelled on: Analytics dashboards
- Visible tests: zero viewers is zero average; real traffic computes normally
- Reward: 50 XP for a complete fix
Briefing
Inspired by every analytics dashboard that has proudly displayed "Infinity minutes" or "NaN%" on launch day, before any traffic arrived. Division needs a denominator.
metrics.js computes the overview cards.
Bug report
BUG-INF · Reported by: dashboards
- avgWatchMs(totalMs, viewers): 0 viewers -> 0
- clickRate(clicks, views): percentage with ONE decimal; 0 views -> 0
Observed: fresh channels show "Infinity" and "NaN%" cards.
Logs
[cards] avg watch: Infinity min · CTR: NaN%The code as shipped
src/stats/metrics.js (editable)
// Overview card metrics.
exports.avgWatchMs = function (totalMs, viewers) {
return Math.round(totalMs / viewers);
};
exports.clickRate = function (clicks, views) {
return Math.round((clicks / views) * 1000) / 10;
};
Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More JavaScript bug hunts.