File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 1- function setAlarm ( ) { }
1+ function setAlarm ( ) {
2+ const inputSeconds = document . getElementById ( "alarmSet" ) ;
3+ const displayTimer = document . getElementById ( "timeRemaining" )
4+
5+ let remainingSeconds = Number ( inputSeconds . value ) ;
6+
7+ const countDownInterval = setInterval ( ( ) => {
8+ if ( remainingSeconds < 0 ) {
9+ clearInterval ( countDownInterval ) ;
10+ playAlarm ( ) ;
11+ inputSeconds . value = '' ;
12+ document . body . style . backgroundColor = 'lightgreen' ;
13+ return
14+ }
15+
16+ const minutes = Math . floor ( remainingSeconds / 60 ) ;
17+ const seconds = remainingSeconds % 60 ;
18+
19+ displayTimer . innerHTML = `Time Remaining: ${ String ( minutes ) . padStart ( 2 , "0" ) } :${ String ( seconds ) . padStart ( 2 , "0" ) } ` ;
20+ remainingSeconds -= 1 ;
21+ } , 1000 ) ;
22+
23+ }
224
325// DO NOT EDIT BELOW HERE
426
You can’t perform that action at this time.
0 commit comments