Skip to content

Commit b4bde21

Browse files
committed
handl zero input and empty input
1 parent ee63ed7 commit b4bde21

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sprint-3/alarmclock/alarmclock.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,24 @@ function updateDisplay() {
1111

1212
function startCountdown() {
1313
timerId = setInterval(() => {
14-
remainingSeconds -= 1;
14+
1515
updateDisplay();
16-
if (remainingSeconds === 0) {
16+
if (remainingSeconds <= 0) {
1717
remainingSeconds = 0;
1818
clearInterval(timerId);
1919
timerId = null;
2020
playAlarm();
2121
}
22+
remainingSeconds -= 1;
2223
}, 1000);
2324
}
2425

2526
function setAlarm() {
2627
const input = document.getElementById("alarmSet");
28+
if (input.value==="")return;
2729
const inputValue = Number(input.value);
30+
31+
2832
clearInterval(timerId);
2933
timerId = null;
3034
remainingSeconds = inputValue;

0 commit comments

Comments
 (0)