Skip to content

Commit a349242

Browse files
committed
fix: Understanding and explain the behavior of formatTimeDisplay() and pad() in sprint -2/ time-format.js
1 parent 1c4a2db commit a349242

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function formatTimeDisplay(seconds) {
1111
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1212
}
1313

14-
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
14+
// You will need to play computer with this example - use the Python Visualizer https://pythontutor.com/visualize.html#mode=edit
1515
// to help you answer these questions
1616

1717
// Questions
@@ -20,15 +20,18 @@ function formatTimeDisplay(seconds) {
2020
// =============> write your answer here
2121

2222
// Call formatTimeDisplay with an input of 61, now answer the following:
23-
23+
// 3 times which is once each for hours, minutes, and seconds.
2424
// b) What is the value assigned to num when pad is called for the first time?
2525
// =============> write your answer here
26-
26+
// 0, because pad is first called with totalHours, which is 0.
2727
// c) What is the return value of pad is called for the first time?
2828
// =============> write your answer here
29-
29+
// '00' pad(0) becomes "0" → padded to "00" using padStart(2, "0").
3030
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3131
// =============> write your answer here
32-
32+
// 1, because the last call to pad is with remainingSeconds, which is 1.
3333
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
3434
// =============> write your answer here
35+
// "01", pad(1) becomes "1" → padded to "01" using padStart(2, "0").
36+
37+
// the final output of formatTimeDisplay(61) will be "00:01:01".

0 commit comments

Comments
 (0)