11function pad ( num ) {
22 return num . toString ( ) . padStart ( 2 , "0" ) ;
3+
34}
45
56function formatTimeDisplay ( seconds ) {
67 const remainingSeconds = seconds % 60 ;
78 const totalMinutes = ( seconds - remainingSeconds ) / 60 ;
89 const remainingMinutes = totalMinutes % 60 ;
910 const totalHours = ( totalMinutes - remainingMinutes ) / 60 ;
10-
1111 return `${ pad ( totalHours ) } :${ pad ( remainingMinutes ) } :${ pad ( remainingSeconds ) } ` ;
1212}
1313formatTimeDisplay ( 60 ) ;
@@ -18,18 +18,18 @@ formatTimeDisplay(60);
1818// Questions
1919
2020// a) When formatTimeDisplay is called how many times will pad be called?
21- // =============> write your answer here. one time
21+ // =============> 3 times
2222
2323// Call formatTimeDisplay with an input of 61, now answer the following:
2424
2525// b) What is the value assigned to num when pad is called for the first time?
26- // =============> write your answer here .is 60
26+ // =============> .is 0 ,because totalHours = 0 at that point.
2727
2828// c) What is the return value of pad is called for the first time?
29- // =============> write your answer here is 0
29+ // =============> is "00"
3030
3131// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
32- // =============> write your answer here
32+ // =============> num = 1 ,because last call to pad is for remainingMinutes, which is = 1
3333
3434// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
35- // =============> write your answer here
35+ // =============> "01" because pad(1) converts 1 to a string and pads it to two digits, resulting in "01"
0 commit comments