Skip to content

Commit c1008ba

Browse files
committed
Add timer clearing logic to setAlarm function for repeated button clicks
1 parent b59497e commit c1008ba

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎Sprint-3/alarmclock/alarmclock.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ function setAlarm() {
1010
if (isNaN(totalSeconds) || totalSeconds < 0) {
1111
totalSeconds = 0;
1212
}
13+
// Clear any existing timer if the button is clicked again
14+
if (timerInterval) {
15+
clearInterval(timerInterval);
16+
}
1317
}
1418

1519
// DO NOT EDIT BELOW HERE

0 commit comments

Comments
 (0)