Skip to content

Commit a20ef05

Browse files
committed
Fix setAlarm function to return early for invalid or empty input values
1 parent 54ce687 commit a20ef05

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎Sprint-3/alarmclock/alarmclock.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ function setAlarm() {
77
let totalSeconds = parseInt(inputEl.value, 10);
88

99
// If input is invalid or empty, default to 0
10-
if (isNaN(totalSeconds) || totalSeconds < 0) {
11-
totalSeconds = 0;
10+
if (isNaN(totalSeconds) || totalSeconds <= 0) {
11+
return;
1212
}
1313
// Clear any existing timer if the button is clicked again
1414
if (timerInterval) {

0 commit comments

Comments
 (0)