File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ function formatTime(seconds) {
1010
1111function setAlarm ( ) {
1212 let seconds = parseInt ( document . getElementById ( "alarmSet" ) . value ) ;
13+ if ( ! Number . isFinite ( seconds ) || seconds < 1 ) {
14+ throw new Error ( "Please enter a valid number greater than 0" ) ;
15+ }
1316 clearInterval ( countdown ) ;
1417 document . getElementById ( "timeRemaining" ) . textContent =
1518 "Time Remaining: " + formatTime ( seconds ) ;
@@ -21,7 +24,7 @@ function setAlarm() {
2124
2225 if ( seconds <= 0 ) {
2326 clearInterval ( countdown ) ;
24- document . body . classList . add ( "alarm-finished" )
27+ document . body . classList . add ( "alarm-finished" ) ;
2528 playAlarm ( ) ;
2629 }
2730 } , 1000 ) ;
@@ -44,7 +47,7 @@ function playAlarm() {
4447function pauseAlarm ( ) {
4548 clearInterval ( countdown ) ;
4649 audio . pause ( ) ;
47- document . body . classList . remove ( "alarm-finished" )
50+ document . body . classList . remove ( "alarm-finished" ) ;
4851}
4952
5053window . onload = setup ;
You can’t perform that action at this time.
0 commit comments