File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,16 +23,24 @@ function formatTime(totalSeconds) {
2323 */
2424function updateTime ( ) {
2525 timeRemainingInSeconds = timeRemainingInSeconds - 1 ;
26- titleElement . innerText = formatTime ( timeRemainingInSeconds ) ;
26+ displayTime ( ) ;
2727
2828 if ( timeRemainingInSeconds === 0 ) {
2929 playAlarm ( ) ;
3030 document . body . classList . add ( "flash" ) ;
3131 clearInterval ( alarmTimerIdentifier ) ;
32- alarmTimerIdentifier = null ; // ← reset to null for proper state management
32+ alarmTimerIdentifier = null ; // Reset to null for proper state management
3333 }
3434}
3535
36+ /**
37+ * Displays the remaining time.
38+ */
39+ function displayTime ( ) {
40+ const titleElement = document . getElementById ( "timeRemaining" ) ;
41+ titleElement . innerText = formatTime ( timeRemainingInSeconds ) ;
42+ }
43+
3644/**
3745 * Initialises the alarm countdown.
3846 */
@@ -59,7 +67,7 @@ function setAlarm() {
5967 audio . play ( ) ;
6068 audio . pause ( ) ;
6169
62- titleElement . innerText = formatTime ( timeRemainingInSeconds ) ;
70+ displayTime ( ) ;
6371
6472 alarmTimerIdentifier = setInterval ( ( ) => {
6573 updateTime ( ) ;
You can’t perform that action at this time.
0 commit comments