@@ -15,24 +15,28 @@ function formatTimeDisplay(seconds) {
1515 return `${ pad ( totalHours ) } :${ pad ( remainingMinutes ) } :${ pad ( remainingSeconds ) } ` ;
1616}
1717
18- // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
18+ // You will need to play computer with this example - use the Python Visualiser
1919// to help you answer these questions
2020
2121// Questions
2222
2323// a) When formatTimeDisplay is called how many times will pad be called?
24- // =============> write your answer here
24+ // pad will be called 3 times.
2525
2626// Call formatTimeDisplay with an input of 61, now answer the following:
2727
2828// b) What is the value assigned to num when pad is called for the first time?
29- // =============> write your answer here
29+ // The value assigned to num is 0.
3030
3131// c) What is the return value of pad when it is called for the first time?
32- // =============> write your answer here
32+ // The return value is "00".
3333
34- // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
35- // =============> write your answer here
34+ // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
35+ // The value assigned to num is 1.
36+ // The last call is pad(remainingSeconds), and when the input is 61,
37+ // remainingSeconds is 1.
3638
37- // e) What is the return value of pad when it is called for the last time in this program? Explain your answer
38- // =============> write your answer here
39+ // e) What is the return value of pad when it is called for the last time in this program? Explain your answer
40+ // The return value is "01".
41+ // num is converted to the string "1". Because it has fewer than 2 characters,
42+ // the while loop adds a "0" to the beginning, producing "01".
0 commit comments