File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Sprint-2/4-mandatory-interpret Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -19,16 +19,31 @@ function formatTimeDisplay(seconds) {
1919// a) When formatTimeDisplay is called how many times will pad be called?
2020// =============> write your answer here
2121
22+ // Answer: 3 times
23+ // pad(totalHours)
24+ // pad(remainingMinutes)
25+ // pad(remainingSeconds)
26+
27+
2228// Call formatTimeDisplay with an input of 61, now answer the following:
2329
2430// b) What is the value assigned to num when pad is called for the first time?
2531// =============> write your answer here
32+ pad ( num ) = pad ( 0 ) = 0
2633
2734// c) What is the return value of pad is called for the first time?
2835// =============> write your answer here
36+ pad ( num ) = pad ( 0 ) = "00"
2937
3038// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3139// =============> write your answer here
40+ // pad(num) = pad(1) = 1
41+
42+ //Explanation
43+ // Last call: pad(remainingSeconds)
44+ // remainingSeconds = 1
45+ // pad(1) → num = 1
3246
3347// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
3448// =============> write your answer here
49+ // pad(num) = pad(1) = "01" because the pad function converts the number to a string and pads it with a leading zero if it's only one digit long.
You can’t perform that action at this time.
0 commit comments