Skip to content

Commit 2ef3cb2

Browse files
committed
completed 4-mandatory-interpret
1 parent 7bc25aa commit 2ef3cb2

File tree

1 file changed

+12
-6
lines changed

1 file changed

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

6+
7+
58
function formatTimeDisplay(seconds) {
69
const remainingSeconds = seconds % 60;
710
const totalMinutes = (seconds - remainingSeconds) / 60;
@@ -11,24 +14,27 @@ function formatTimeDisplay(seconds) {
1114
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1215
}
1316

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

1722
// Questions
1823

1924
// a) When formatTimeDisplay is called how many times will pad be called?
2025
// =============> write your answer here
26+
// 3 times.
2127

2228
// Call formatTimeDisplay with an input of 61, now answer the following:
23-
29+
//
2430
// b) What is the value assigned to num when pad is called for the first time?
25-
// =============> write your answer here
31+
// 0.
2632

2733
// c) What is the return value of pad is called for the first time?
28-
// =============> write your answer here
34+
// 00.
2935

3036
// 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
37+
// 1, this is because they assign remainingSeconds to num for the last time pad is called.
3238

33-
// 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
39+
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer - "do you mean the return value for pad?"
40+
// 01, this is the result of calling pad for the last time.

0 commit comments

Comments
 (0)