@@ -17,21 +17,26 @@ function formatTimeDisplay(seconds) {
1717// Questions
1818
1919// a) When formatTimeDisplay is called how many times will pad be called?
20- // =============> pad is called 3 times — once for hours, once for minutes, and once for seconds.
20+ // =============> pad is called 3 times — once each for hours, for minutes andvfor seconds.
2121
2222
2323// Call formatTimeDisplay with an input of 61, now answer the following:
2424
2525// b) What is the value assigned to num when pad is called for the first time?
26- // =============> pad is first called for total hourse which is 0 hours
26+ // =============> The first call is for totalHours, and when you call formatTimeDisplay(61), the value of totalHours is:
27+ //totalHours = (61 - 1) / 60 = 60 / 60 = 1, remainingMinutes = 1
28+ //totalHours = totalMinutes - remainingMinutes = 1 - 1 = 0
29+ // So, num = 0 for the first pad call.
2730
2831// c) What is the return value of pad is called for the first time?
29- // =============> the return value is "00"
32+ // =============> The return value is "00" because pad(0) results in "00" using .padStart(2, "0").
3033
3134// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
32- // =============> pad is called for total seconds at last time which is 1 seconds .
35+ // =============> The last call is for remaining seconds. With input 61, remainingSeconds = 61 % 60 = 1, so num = 1 in the last call .
3336
3437// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
35- // =============> the return value is "01".It pads "1" with a leading zero to ensure two digits.
38+ // =============> The return value is "01" – pad(1) returns "01" because it adds a leading zero to make it 2 characters.
39+
40+ // so final output should be "00:01:01"
3641
3742
0 commit comments