File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11function setAlarm ( ) {
22 timeRemaining = document . getElementById ( "timeRemaining" )
3- alarmSet = document . getElementById ( "alarmSet" ) . value
4-
3+ timeSet = document . getElementById ( "alarmSet" ) . value
4+ const time = convertTime ( timeSet )
55
66
77
@@ -11,7 +11,7 @@ function setAlarm() {
1111
1212function countdown ( time ) {
1313 setInterval ( ( ) => {
14-
14+
1515 } , 1000 )
1616}
1717
@@ -23,6 +23,16 @@ function convertTime(timeSeconds) {
2323 return [ minutes , seconds ] ;
2424}
2525
26+ function printTime ( time ) {
27+ const paddedHours = String ( time [ 0 ] ) . padStart ( 2 , "0" ) ;
28+ const paddedSeconds = String ( time [ 1 ] ) . padStart ( 2 , "0" ) ;
29+ return paddedHours + ":" + paddedSeconds ;
30+ }
31+
32+ printTime ( [ 50 , 40 ] )
33+ printTime ( [ 50 , 4 ] )
34+ printTime ( [ 5 , 40 ] )
35+
2636convertTime ( 5000000 )
2737convertTime ( 50 )
2838convertTime ( 500 )
You can’t perform that action at this time.
0 commit comments