@@ -10,25 +10,39 @@ function formatTimeDisplay(seconds) {
1010
1111 return `${ pad ( totalHours ) } :${ pad ( remainingMinutes ) } :${ pad ( remainingSeconds ) } ` ;
1212}
13-
13+ console . log ( formatTimeDisplay ( 61 ) ) ;
1414// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1515// to help you answer these questions
1616
1717// Questions
1818
1919// a) When formatTimeDisplay is called how many times will pad be called?
2020// =============> write your answer here
21+ //when the function formatTimeDisplay when is called, the pad function will call 3 times.
2122
2223// Call formatTimeDisplay with an input of 61, now answer the following:
2324
2425// b) What is the value assigned to num when pad is called for the first time?
2526// =============> write your answer here
27+ // The assign value to num when it first call is 0.
2628
2729// c) What is the return value of pad is called for the first time?
2830// =============> write your answer here
31+ // The return value of pad for the first time is 0.
2932
3033// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3134// =============> write your answer here
3235
36+ /*The assign value to num when the function pad when it
37+ last called will be 1. Because when the pad function called for the third time, it will
38+ receive the value from the variable remainingSeconds(seconds % 60 = 1);
39+ */
40+
3341// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
3442// =============> write your answer here
43+ /*
44+ the assign return value to num when the function pad when it last called will be 01,
45+ because the when the value remainingSeconds pass into the pad function. It will
46+ turn into string that will be add and combine "0" into the string "1" to the left because the padStart method check the total
47+ length of the string "1" and it is less then 2.
48+ */
0 commit comments