Skip to content

Commit 97da7db

Browse files
committed
Answering the task time-format
1 parent c14e9d7 commit 97da7db

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
function pad(num) {
23
return num.toString().padStart(2, "0");
34
}
@@ -10,25 +11,25 @@ function formatTimeDisplay(seconds) {
1011

1112
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1213
}
13-
14+
console.log(formatTimeDisplay(61));
1415
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1516
// to help you answer these questions
1617

1718
// Questions
1819

1920
// a) When formatTimeDisplay is called how many times will pad be called?
20-
// =============> write your answer here
21+
// =============> It will be called 3 times.
2122

2223
// Call formatTimeDisplay with an input of 61, now answer the following:
2324

2425
// b) What is the value assigned to num when pad is called for the first time?
25-
// =============> write your answer here
26+
// =============> 0
2627

2728
// c) What is the return value of pad is called for the first time?
28-
// =============> write your answer here
29+
// =============> 00
2930

3031
// 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
32+
// =============> The leftover second is assigned to num as remainingSEconds 61%60
3233

3334
// 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
35+
// =============> 01 the remainingSeconds from passed from pad to num is changed to string and padded as 01

0 commit comments

Comments
 (0)