11let timer ;
22
33function setAlarm ( ) {
4- timeSet = document . getElementById ( "alarmSet" ) . value
5- const time = countdown ( timeSet )
4+ timeSet = document . getElementById ( "alarmSet" ) . value ;
5+ const time = countdown ( timeSet ) ;
66 if ( time > 0 ) {
77 countdown ( time ) ;
88 }
@@ -11,14 +11,19 @@ function setAlarm() {
1111function countdown ( time ) {
1212 clearInterval ( timer ) ;
1313 let timeRemaining = time ;
14- if ( timeRemaining > 5999 ) { timeRemaining = 5999 } ;
15- UpdateShownTime ( timeRemaining )
16-
14+ if ( timeRemaining > 5999 ) {
15+ timeRemaining = 5999 ;
16+ }
17+ UpdateShownTime ( timeRemaining ) ;
18+
1719 timer = setInterval ( ( ) => {
1820 timeRemaining -= 1 ;
19- if ( timeRemaining == 0 ) { clearInterval ( timer ) ; playAlarm ( ) ; }
20- UpdateShownTime ( timeRemaining )
21- } , 1000 )
21+ if ( timeRemaining == 0 ) {
22+ clearInterval ( timer ) ;
23+ playAlarm ( ) ;
24+ }
25+ UpdateShownTime ( timeRemaining ) ;
26+ } , 1000 ) ;
2227}
2328
2429function UpdateShownTime ( timeRemaining ) {
@@ -33,7 +38,7 @@ function UpdateShownTime(timeRemaining) {
3338function convertTime ( timeSeconds ) {
3439 const seconds = timeSeconds % 60 ;
3540 const minutes = ( timeSeconds - seconds ) / 60 ;
36- console . log ( [ minutes , seconds ] )
41+ console . log ( [ minutes , seconds ] ) ;
3742 return [ minutes , seconds ] ;
3843}
3944
@@ -43,7 +48,6 @@ function printTime(time) {
4348 return paddedHours + ":" + paddedSeconds ;
4449}
4550
46-
4751// DO NOT EDIT BELOW HERE
4852
4953var audio = new Audio ( "alarmsound.mp3" ) ;
0 commit comments