We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6cb11f7 commit 6b7e254Copy full SHA for 6b7e254
Sprint-3/alarmclock/alarmclock.js
@@ -18,7 +18,6 @@ function setAlarm() {
18
timeLeft = parseInt(input, 10);
19
20
if (isNaN(timeLeft) || timeLeft <= 0) {
21
- alert("Please enter a valid number of seconds.");
22
return;
23
}
24
@@ -29,13 +28,14 @@ function setAlarm() {
29
28
updateDisplay(timeLeft);
30
31
timer = setInterval(() => {
32
- if (timeLeft > 0) {
33
- timeLeft--;
34
- updateDisplay(timeLeft);
35
- } else {
+ if (timeLeft <= 0) {
36
clearInterval(timer);
37
playAlarm();
+ return;
38
+
+ timeLeft--;
+ updateDisplay(timeLeft);
39
}, 1000);
40
41
0 commit comments