Skip to content

Commit 2e0abd1

Browse files
committed
Add explanations for pad function calls in formatTimeDisplay
1 parent dd9a89c commit 2e0abd1

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,29 @@ function formatTimeDisplay(seconds) {
2222

2323
// a) When formatTimeDisplay is called how many times will pad be called?
2424
// =============> write your answer here
25+
//The function pad will be called 3 times when formatTimeDisplay is called,
26+
//once for totalHours, once for remainingMinutes, and once for remainingSeconds.
2527

2628
// Call formatTimeDisplay with an input of 61, now answer the following:
2729

2830
// b) What is the value assigned to num when pad is called for the first time?
2931
// =============> write your answer here
32+
//The value assigned to num when pad is called for the first time is 0,
33+
//because 61 seconds is equal to 1 minute and 1 second, which means totalHours is 0.
3034

3135
// c) What is the return value of pad is called for the first time?
3236
// =============> write your answer here
37+
//The return value of pad when it is called for the first time is "00",
38+
//because the value of num is 0, and the function pad adds a leading zero to
39+
// make it a two-digit string.
3340

3441
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3542
// =============> write your answer here
43+
//The value assigned to num when pad is called for the last time in this program is 1,
44+
//because 61 seconds is equal to 1 minute and 1 second, which means remainingSeconds is 1.
3645

3746
// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
3847
// =============> write your answer here
48+
//The return value of pad when it is called for the last time in this program is "01",
49+
//because the value of num is 1, and the function pad adds a leading zero to
50+
// make it a two-digit string.

0 commit comments

Comments
 (0)