Skip to content

Commit 57f5291

Browse files
committed
moving the clear alarm timeout from below line 61 (lines 81-84) and placing in the guards line 33
1 parent 39e4ac5 commit 57f5291

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

Sprint-3/alarmclock/alarmclock.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ function setAlarm() {
3333
clearInterval(countdownId);
3434
}
3535

36+
// Clear the alarm timeout if it exists
37+
if (alarmTimeoutId !== null) {
38+
clearTimeout(alarmTimeoutId);
39+
alarmTimeoutId = null;
40+
}
41+
3642
// Reset background and stop alarm sound when setting a new alarm
3743
document.body.style.backgroundColor = originalBackgroundColor;
3844
pauseAlarm();
@@ -78,11 +84,6 @@ function playAlarm() {
7884

7985
function pauseAlarm() {
8086
audio.pause();
81-
// Clear the alarm timeout if it exists
82-
if (alarmTimeoutId !== null) {
83-
clearTimeout(alarmTimeoutId);
84-
alarmTimeoutId = null;
85-
}
8687
}
8788

8889
window.onload = setup;

0 commit comments

Comments
 (0)