File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- function setAlarm ( ) { }
1+ function setAlarm ( ) {
2+ let time = Number ( document . getElementById ( "alarmSet" ) . value ) ;
3+ let heading = document . getElementById ( "timeRemaining" ) ;
24
5+ function updateClock ( ) {
6+ let minutes = Math . floor ( time / 60 ) ;
7+ let seconds = time % 60 ;
8+
9+ minutes = String ( minutes ) . padStart ( 2 , "0" ) ;
10+ seconds = String ( seconds ) . padStart ( 2 , "0" ) ;
11+
12+ heading . innerText = `Time Remaining: ${ minutes } :${ seconds } ` ;
13+
14+ if ( time === 0 ) {
15+ clearInterval ( timer ) ;
16+ playAlarm ( ) ;
17+ }
18+
19+ time -- ;
20+ }
21+
22+ updateClock ( ) ;
23+ let timer = setInterval ( updateClock , 1000 ) ;
24+ }
325// DO NOT EDIT BELOW HERE
426
527var audio = new Audio ( "alarmsound.mp3" ) ;
Original file line number Diff line number Diff line change 44 < meta charset ="utf-8 " />
55 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
66 < link rel ="stylesheet " href ="style.css " />
7- < title > Title here </ title >
7+ < title > Alarm Clock </ title >
88 </ head >
99 < body >
1010 < div class ="centre ">
Original file line number Diff line number Diff line change 1313 "bugs" : {
1414 "url" : " https://github.com/CodeYourFuture/CYF-Coursework-Template/issues"
1515 },
16- "homepage" : " https://github.com/CodeYourFuture/CYF-Coursework-Template#readme"
16+ "homepage" : " https://github.com/CodeYourFuture/CYF-Coursework-Template#readme" ,
17+ "devDependencies" : {
18+ "@testing-library/jest-dom" : " ^6.9.1" ,
19+ "jest-environment-jsdom" : " ^30.4.1" ,
20+ "jsdom" : " ^20.0.3"
21+ }
1722}
You can’t perform that action at this time.
0 commit comments