@@ -18,17 +18,27 @@ function formatTimeDisplay(seconds) {
1818
1919// a) When formatTimeDisplay is called how many times will pad be called?
2020// =============> write your answer here
21+ // Three 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
26-
27+ /* The first time pad() run, its used for hours part of time.
28+ Because 61 seconds equals 0 hours, the value given to num is 0. */
2729// c) What is the return value of pad is called for the first time?
2830// =============> write your answer here
31+ /* The first time pad() runs, it's formatting the hours part of time.
32+ Since the hours value is 0, it turns that into the string '00' by adding a leading zero before returning it. */
2933
3034// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3135// =============> write your answer here
36+ /* When the function runs with 61 seconds, the last time pad() is called is for the second part of the time.
37+ Since 61 seconds has 1 second left over after making a full minute, the value passed into pad() is 1.
38+ Inside the function, num equals 1, and it gets turned into '01' so the final time shows as 00:01:01. */
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+ /* When pad() is called for the last time, num is 1 because there's 1 second left over.
43+ The function turns that number into the string '01' by adding a leading zero.
44+ That '01' is the value that gets returned and used as the seconds part of the final time display (00:01:01). */
0 commit comments