Skip to content

Commit 489671d

Browse files
Refactor comments in time-format.js to clarify function behavior and provide answers to questions
1 parent 9cd4aff commit 489671d

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,24 +11,27 @@ function formatTimeDisplay(seconds) {
1111
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1212
}
1313

14+
console.log(formatTimeDisplay(10002));
15+
1416
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1517
// to help you answer these questions
1618

1719
// Questions
1820

1921
// a) When formatTimeDisplay is called how many times will pad be called?
20-
// =============> write your answer here
22+
// =============> pad will be called 3 times, once for each of the hours, minutes and seconds.
2123

2224
// Call formatTimeDisplay with an input of 61, now answer the following:
2325

2426
// b) What is the value assigned to num when pad is called for the first time?
25-
// =============> write your answer here
27+
// =============> num is assigned the value of 0, because 61 seconds is equal to 1 minute and 1 second, so the total hours is 0.
2628

2729
// c) What is the return value of pad is called for the first time?
28-
// =============> write your answer here
30+
// =============> The return value is "00", because pad pads the number 0 to 2 digits with leading zeros.
2931

3032
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
31-
// =============> write your answer here
33+
// =============> num is assigned the value of 1, because 61 seconds is equal to 1 minute and 1 second,
34+
// so the remaining seconds is 1.
3235

3336
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
34-
// =============> write your answer here
37+
// =============> The return value is "01", because pad pads the number 1 to 2 digits with leading zeros.

0 commit comments

Comments
 (0)