Skip to content

Commit 4fd9db6

Browse files
committed
time-format file update
1 parent c697a4d commit 4fd9db6

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,34 @@ 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+
// pad will be called 3 times
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+
// The value assigned to num when pad is called for the first
32+
// time is 0 (the value of totalHours).
3033

3134
// c) What is the return value of pad is called for the first time?
32-
// =============> write your answer here
35+
// The return value of pad when it is called for the first time is "00"
36+
// because 0 is padded with a leading zero.
3337

3438
// 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
39+
//The value assigned to num when pad is called for the
40+
// last time is 1 (the value of remainingSeconds).
41+
// This is because the return statement is executed from left to right, so the order of pad calls is: totalHours, remainingMinutes, and finally remainingSeconds.
42+
43+
3644

3745
// 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
46+
//The return value of pad when it is called for the last time is "01" because 1 is padded with a leading zero.
47+
48+
// The final output of formatTimeDisplay(61) will be "00:01:01".

0 commit comments

Comments
 (0)