@@ -11,24 +11,32 @@ function formatTimeDisplay(seconds) {
1111 return `${ pad ( totalHours ) } :${ pad ( remainingMinutes ) } :${ pad ( remainingSeconds ) } ` ;
1212}
1313
14+
15+ console . log ( formatTimeDisplay ( 61 ) ) ;
16+
1417// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1518// to help you answer these questions
1619
1720// Questions
1821
1922// a) When formatTimeDisplay is called how many times will pad be called?
2023// =============> write your answer here
24+ // it will be called 3 times, because in the return statement we called it 3 times, once for hours, once for minutes and once for seconds.
2125
2226// Call formatTimeDisplay with an input of 61, now answer the following:
2327
2428// b) What is the value assigned to num when pad is called for the first time?
2529// =============> write your answer here
30+ // the value assigned to num is totalHours which is 0.
2631
2732// c) What is the return value of pad is called for the first time?
2833// =============> write your answer here
29-
34+ // it is 00
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 is 1, because remainingSeconds = 1
3238
3339// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
3440// =============> write your answer here
41+ //The return value of pad(1) is "01".
42+ //That’s because inside pad, the number 1 becomes the string "1", and then padStart(2, "0") adds a leading zero to make it two digits.
0 commit comments