Skip to content

Commit 2e8d8de

Browse files
authored
Clarify comments regarding pad function behavior
Updated comments to clarify the behavior of the pad function in time formatting.
1 parent 38c48aa commit 2e8d8de

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

Sprint-2/4-mandatory-interpret/time-format.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@ function formatTimeDisplay(seconds) {
2121
// Questions
2222

2323
// a) When formatTimeDisplay is called how many times will pad be called?
24-
// =============> write your answer here
24+
// pad() is called 3 times because it is used once for hours, once for minutes, and once for seconds.
2525

2626
// Call formatTimeDisplay with an input of 61, now answer the following:
2727

2828
// b) What is the value assigned to num when pad is called for the first time?
29-
// =============> write your answer here
29+
// Because the first call to pad() is pad(totalHours), and formatTimeDisplay(61) calculates totalHours as 0, the value passed to pad() as num is 0.
3030

31-
// c) What is the return value of pad is called for the first time?
32-
// =============> write your answer here
31+
// c) What is the return value of pad when called for the first time?
32+
// When pad() is called for the first time, num is 0 because totalHours is 0.
33+
// The function converts it to a string and adds a leading zero, so the return value is "00".
3334

34-
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
35-
// =============> write your answer here
35+
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
36+
// Because the last call to pad() is pad(remainingSeconds) and formatTimeDisplay(61) calculates remainingSeconds as 1 (61 % 60 = 1), the value passed into pad() as num is 1.
3637

37-
// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
38-
// =============> write your answer here
38+
// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
39+
// The return value of pad() when it is called for the last time is "01" because num is 1, and the function pads numbers by adding a leading zero.

0 commit comments

Comments
 (0)