Skip to content

Commit d61207f

Browse files
committed
Fix setAlarm function to handle invalid input and added a error message as user feedback
1 parent f6577e7 commit d61207f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎Sprint-3/alarmclock/alarmclock.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ function setAlarm() {
88

99
// If input is invalid or empty, default to 0
1010
if (isNaN(totalSeconds) || totalSeconds <= 0) {
11+
if (timerInterval) clearInterval(timerInterval); // Stop any running timer
12+
timeRemainingEl.innerText = "Please enter a valid time (greater than 0)"; // Inform the user
1113
return;
1214
}
1315
// Clear any existing timer if the button is clicked again

0 commit comments

Comments
 (0)