11function pad ( num ) {
2- let numString = num . toString ( ) ;
3- while ( numString . length < 2 ) {
4- numString = "0" + numString ;
5- }
6- return numString ;
2+ let numString = num . toString ( ) ;
3+ while ( numString . length < 2 ) {
4+ numString = '0' + numString ;
5+ }
6+ return numString ;
77}
88
99function formatTimeDisplay ( seconds ) {
10- const remainingSeconds = seconds % 60 ;
11- const totalMinutes = ( seconds - remainingSeconds ) / 60 ;
12- const remainingMinutes = totalMinutes % 60 ;
13- const totalHours = ( totalMinutes - remainingMinutes ) / 60 ;
10+ const remainingSeconds = seconds % 60 ;
11+ const totalMinutes = ( seconds - remainingSeconds ) / 60 ;
12+ const remainingMinutes = totalMinutes % 60 ;
13+ const totalHours = ( totalMinutes - remainingMinutes ) / 60 ;
1414
15- return `${ pad ( totalHours ) } :${ pad ( remainingMinutes ) } :${ pad ( remainingSeconds ) } ` ;
15+ return `${ pad ( totalHours ) } :${ pad ( remainingMinutes ) } :${ pad ( remainingSeconds ) } ` ;
1616}
17- console . log ( formatTimeDisplay ( 61 ) )
17+ console . log ( formatTimeDisplay ( 61 ) ) ;
1818
1919// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
2020// to help you answer these questions
@@ -43,4 +43,4 @@ console.log(formatTimeDisplay(61))
4343// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
4444// =============> write your answer here
4545// The return value is "01" because the last call to pad is pad(1).
46- // The pad function add a zero to make the number two digits.
46+ // The pad function add a zero to make the number two digits.
0 commit comments