File tree Expand file tree Collapse file tree
Sprint-3/4-mandatory-interpret Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,17 +22,25 @@ function formatTimeDisplay(seconds) {
2222
2323// a) When formatTimeDisplay is called how many times will pad be called?
2424// =============> write your answer here
25+ // 3 times. The return line calls pad once each for hours, minutes and seconds.
2526
2627// Call formatTimeDisplay with an input of 61, now answer the following:
2728
2829// b) What is the value assigned to num when pad is called for the first time?
2930// =============> write your answer here
31+ // 0. The first call is pad(totalHours), and totalHours is 0 for an input of 61.
3032
3133// c) What is the return value of pad when it is called for the first time?
3234// =============> write your answer here
35+ // "00". num.toString() gives "0", which is shorter than 2 characters, so the
36+ // while loop adds one "0" to the front. pad always returns a string.
3337
3438// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3539// =============> write your answer here
40+ // 1. The last call is pad(remainingSeconds), and remainingSeconds is 61 % 60 = 1.
3641
3742// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
3843// =============> write your answer here
44+ // "01". num.toString() gives "1", which is too short, so the loop adds a "0"
45+ // to the front.
46+ console . log ( formatTimeDisplay ( 61 ) ) ;
You can’t perform that action at this time.
0 commit comments