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 9c3ee51 commit bffd4b4Copy full SHA for bffd4b4
Sprint-3/alarmclock/alarmclock.js
@@ -25,10 +25,22 @@ updateDisplay(0);
25
// -------------------------------
26
27
function setAlarm() {
28
- const input = document.getElementById("alarmSet").value;
29
- const parsed = parseInt(input, 10);
+ const inputEl = document.getElementById("alarmSet");
+const input = inputEl.value.trim();
30
31
- if (isNaN(parsed) || parsed < 0) return;
+// Check empty input
32
+if (input === "") {
33
+ alert("Please enter a number of seconds.");
34
+ return;
35
+}
36
+
37
+const parsed = parseInt(input, 10);
38
39
+// Check invalid or negative number
40
+if (isNaN(parsed) || parsed < 0) {
41
+ alert("Please enter a valid non-negative number.");
42
43
44
45
timeLeft = parsed;
46
0 commit comments