File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 1- function setAlarm ( ) { }
1+ function setAlarm ( ) {
2+ const input = document . getElementById ( "alarmSet" ) . value ;
3+ const heading = document . getElementById ( "timeRemaining" ) ;
4+
5+ let totalSeconds = Number ( input ) ;
6+
7+ function updateDisplay ( seconds ) {
8+ const min = Math . floor ( seconds / 60 ) ;
9+ const secs = seconds % 60 ;
10+
11+ const formattedMin = String ( min ) . padStart ( 2 , "0" ) ;
12+ const formattedSecs = String ( secs ) . padStart ( 2 , "0" ) ;
13+
14+ heading . innerText = `Time Remaining: ${ formattedMin } :${ formattedSecs } ` ;
15+ }
16+ updateDisplay ( totalSeconds ) ;
17+
18+ const timer = setInterval ( ( ) => {
19+ totalSeconds -- ;
20+
21+ if ( totalSeconds <= 0 ) {
22+ updateDisplay ( 0 ) ;
23+ clearInterval ( timer ) ;
24+ playAlarm ( ) ;
25+ } else {
26+ updateDisplay ( totalSeconds ) ;
27+ }
28+ } , 1000 ) ;
29+ }
230
331// DO NOT EDIT BELOW HERE
432
Original file line number Diff line number Diff line change 2727 "@testing-library/jest-dom" : " ^6.6.3" ,
2828 "@testing-library/user-event" : " ^14.6.1" ,
2929 "jest" : " ^30.0.4" ,
30- "jest-environment-jsdom" : " ^30.0.4 "
30+ "jest-environment-jsdom" : " ^30.3.0 "
3131 }
3232}
You can’t perform that action at this time.
0 commit comments