Skip to content

Commit cad0b79

Browse files
wrote a tatement to validate that the input is a positive number and doesn't exceed 1 hour
1 parent c283013 commit cad0b79

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎Sprint-3/alarmclock/alarmclock.js‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ function setAlarm() {
1313
}
1414

1515
const seconds = Number(input.value);
16-
17-
if (isNaN(seconds) || seconds <= 0) {
18-
alert("Please enter a valid number of seconds.");
16+
//validate that input is a positive integer and doestn't exceed 1 hour
17+
if (
18+
isNaN(seconds) ||
19+
!Number.isInteger(seconds) ||
20+
seconds <= 0 ||
21+
seconds > 3600
22+
) {
23+
alert("Please enter a valid whole number between 1 and 3600.");
1924
return;
2025
}
2126

0 commit comments

Comments
 (0)