File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Sprint-2/4-mandatory-interpret Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -18,17 +18,42 @@ function formatTimeDisplay(seconds) {
1818
1919// a) When formatTimeDisplay is called how many times will pad be called?
2020// =============> write your answer here
21+ // pad(totalHours)
22+ // pad(remainingMinutes)
23+ // pad(remainingSeconds)
24+ // Answer: 3
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+ // formatTimeDisplay:
31+ // seconds = 61
32+ // remainingSeconds = 61 % 60 = 1
33+ // totalMinutes = (61 - 1) / 60 = 1
34+ // remainingMinutes = 1 % 60 = 1
35+ // totalHours = (1 - 1) / 60 = 0
36+ // Answer: pad(num) = pad(0) = 0
2637
2738// c) What is the return value of pad is called for the first time?
2839// =============> write your answer here
40+ // First call: pad(totalHours)
41+ // totalHours = 0
42+ // pad(0) → "00"
43+ // Answer: "00"
2944
3045// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3146// =============> write your answer here
47+ // Last call: pad(remainingSeconds)
48+ // remainingSeconds = 1
49+ // pad(1) → num = 1
50+ // Answer: num = 1
3251
3352// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
3453// =============> write your answer here
54+ // Last call: pad(remainingSeconds)
55+ // remainingSeconds = 1
56+ // toString() → "1"
57+ // "1".padStart(2, "0") → "01"
58+ // pad(1) → "01"
59+ // Answer = "01"
You can’t perform that action at this time.
0 commit comments