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 f9ffdd6 commit b0576a0Copy full SHA for b0576a0
Sprint-3/alarmclock/alarmclock.js
@@ -1,11 +1,21 @@
1
-function setAlarm() {
2
- let timer;
+let timer;
3
+function setAlarm() {
4
const input = document.getElementById("alarmSet").value;
5
let timeLeft = Number(input);
6
7
updateDisplay(timeLeft);
8
9
+ if (input === "" || isNaN(timeLeft)) {
10
+ return;
11
+ }
12
+
13
+ if (timeLeft < 0) {
14
15
16
17
+ updateDisplay(timeLeft);
18
19
clearInterval(timer);
20
21
timer = setInterval(() => {
@@ -24,6 +34,10 @@ function setAlarm() {
24
34
function updateDisplay(secondsLeft) {
25
35
const heading = document.getElementById("timeRemaining");
26
36
37
+ if (secondsLeft < 0) {
38
+ secondsLeft = 0;
39
40
27
41
const minutes = Math.floor(secondsLeft / 60);
28
42
const seconds = secondsLeft % 60;
29
43
0 commit comments