Skip to content

Commit e5f9988

Browse files
fix: update comments for clarity in time-format.js and add console log for testing
1 parent f1241f4 commit e5f9988

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎Sprint-3/4-mandatory-interpret/time-format.js‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,26 @@ function formatTimeDisplay(seconds) {
1515
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1616
}
1717

18+
console.log(formatTimeDisplay(61));
19+
1820
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1921
// to help you answer these questions
2022

2123
// Questions
2224

2325
// a) When formatTimeDisplay is called how many times will pad be called?
24-
// =============> write your answer here
26+
// 3 times (once for hours, once for minutes and once for seconds)
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?
29-
// =============> write your answer here
31+
// With an input of 61 seconds, totalHours evaluates to 0. Therefore, num is assigned 0 on the first call
3032

3133
// c) What is the return value of pad when it is called for the first time?
32-
// =============> write your answer here
34+
// The return value is "00". Since the input is 0, its string length is less than 2, so the while loop runs it twice to prepend two zeros ("00")
3335

3436
// 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
37+
// The value assigned is 1. This is for remainingSeconds, which receives the remainder of 61 % 60, resulting in 1.
3638

3739
// 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
40+
// The return value is "01". Because the input is 1, its string length is less than 2, so the while loop runs once to prepend a single zero("01")

0 commit comments

Comments
 (0)