frontend-interview-questions
frontend-interview-questions copied to clipboard
one sec delay issue solved
Fixes : #15
Where we are formatting the seconds time, I change the value from 59 to 60.
Summary by CodeRabbit
- Bug Fixes
- Corrected the seconds-to-minutes rollover in the countdown timer to align with a true 60-second minute, removing an off-by-one error that could show 60 seconds or miscount at minute transitions.
- Users now see accurate second decrements and reliable minute increments, improving the precision and predictability of the timer display.
Walkthrough
Adjusted countdown rollover logic in machine-coding-interview-questions/countdown-timer/src/script.js: when seconds exceed 60, increment minutes and subtract 60 from seconds (previously 59). No other logic or public interfaces changed.
Changes
| Cohort / File(s) | Summary |
|---|---|
Countdown rollover fixmachine-coding-interview-questions/countdown-timer/src/script.js |
Corrected off-by-one in seconds-to-minutes rollover: when sec.value > 60, increment min.value and set sec.value = parseInt(sec.value) - 60 (was -59). No other changes. |
Sequence Diagram(s)
sequenceDiagram
autonumber
actor User
participant Timer as Timer Tick
participant State as Time State (min, sec)
Note over Timer,State: Per-second tick
User->>Timer: Start countdown
loop Every second
Timer->>State: Decrement sec
alt sec < 0
State->>State: sec += 60<br/>min -= 1
else sec > 60
Note over State: Adjusting overflow
State->>State: min += 1<br/>sec -= 60
end
Timer-->>User: Render updated mm:ss
end
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~8 minutes
Possibly related issues
- piyush-eon/frontend-interview-questions#11 — Addresses the same off-by-one seconds-to-minutes rollover fix in src/script.js.
Poem
A tick, a tock, a tidy tune,
Sixty seconds meet their noon.
Hop! I nudge the minute hand—
No stray second roams the land.
Ears up high, I count with cheer,
Precise as carrots stacked this year. 🥕⏱️
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.