Skip to content

Commit 7afbf41

Browse files
committed
Implement setAlarm function to parse input value and handle invalid or empty inputs
1 parent 01e11ec commit 7afbf41

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎Sprint-3/alarmclock/alarmclock.js‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
function setAlarm() {}
1+
let timerInterval = null;
2+
3+
function setAlarm() {
4+
const inputEl = document.getElementById("alarmSet");
5+
const timeRemainingEl = document.getElementById("timeRemaining");
6+
7+
let totalSeconds = parseInt(inputEl.value, 10);
8+
9+
// If input is invalid or empty, default to 0
10+
if (isNaN(totalSeconds) || totalSeconds < 0) {
11+
totalSeconds = 0;
12+
}
13+
}
214

315
// DO NOT EDIT BELOW HERE
416

0 commit comments

Comments
 (0)