We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e618de2 commit 76f1971Copy full SHA for 76f1971
Sprint-3/alarmclock/alarmclock.js
@@ -54,18 +54,19 @@ if (isNaN(parsed) || parsed < 0) {
54
pauseAlarm(); // stop any playing audio
55
audio.currentTime = 0;
56
57
- // Start countdown every 1000ms
58
- timer = setInterval(() => {
59
- if (timeLeft > 0) {
60
- timeLeft--;
61
- updateDisplay(timeLeft);
62
- }
63
-
64
- if (timeLeft === 0) {
65
- clearInterval(timer);
66
- startAlarm();
67
68
- }, 1000);
+ function tick() {
+ if (timeLeft > 0) {
+ timeLeft--;
+ updateDisplay(timeLeft);
+ } else {
+ clearInterval(timer);
+ startAlarm();
+ }
+}
+
+// Run once immediately for consistency
+tick();
69
+timer = setInterval(tick, 1000);
70
}
71
72
function updateDisplay(seconds) {
0 commit comments