@@ -11,24 +11,33 @@ function formatTimeDisplay(seconds) {
1111 return `${ pad ( totalHours ) } :${ pad ( remainingMinutes ) } :${ pad ( remainingSeconds ) } ` ;
1212}
1313
14+ console . log ( formatTimeDisplay ( 61 ) ) ;
15+
1416// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1517// to help you answer these questions
1618
1719// Questions
1820
1921// a) When formatTimeDisplay is called how many times will pad be called?
2022// =============> write your answer here
23+ // pad will be called 3 times, once for totalHours, once for remainingMinutes and once for remainingSeconds.
2124
2225// Call formatTimeDisplay with an input of 61, now answer the following:
2326
2427// b) What is the value assigned to num when pad is called for the first time?
2528// =============> write your answer here
29+ // The value assigned to num when pad is called for the first time is 0 (totalHours).
2630
2731// c) What is the return value of pad is called for the first time?
2832// =============> write your answer here
33+ // The return value of pad when it is called for the first time is "00"
2934
3035// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3136// =============> write your answer here
37+ // The value assigned to num when pad is called for the last time in this program is 1 (remainingSeconds).
38+ // This is because when we call formatTimeDisplay(61), the remainingSeconds is calculated as 61 % 60 which gives us 1
3239
3340// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
3441// =============> write your answer here
42+ // The return value assigned to num when pad is called for the last time in this program is "01".
43+ // This is because pad(1) returns "01" since 1 is padded to 2 digits with leading zeros.
0 commit comments