You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-2/4-mandatory-interpret/time-format.js
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -18,17 +18,22 @@ function formatTimeDisplay(seconds) {
18
18
19
19
// a) When formatTimeDisplay is called how many times will pad be called?
20
20
// =============> write your answer here
21
+
// When formatTimeDisplay is called, pad will be called three times. This is because pad is called for totalHours, remainingMinutes, and remainingSeconds in the return statement of the formatTimeDisplay function.
21
22
22
23
// Call formatTimeDisplay with an input of 61, now answer the following:
23
24
24
25
// b) What is the value assigned to num when pad is called for the first time?
25
26
// =============> write your answer here
27
+
// When formatTimeDisplay is called with an input of 61, the value assigned to num when pad is called for the first time will be 0. This is because totalHours will be calculated as (totalMinutes - remainingMinutes) / 60, which will be (1 - 1) / 60 = 0. Therefore, pad(0) will be called for the first time.
26
28
27
29
// c) What is the return value of pad is called for the first time?
28
30
// =============> write your answer here
31
+
// The return value of pad when it is called for the first time with num equal to 0 will be "00". This is because pad uses the padStart method to convert the number to a string and pads it with leading zeros until it reaches a length of 2. Therefore, pad(0) will return "00".
29
32
30
33
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
31
34
// =============> write your answer here
35
+
// When formatTimeDisplay is called with an input of 61, the value assigned to num when pad is called for the last time will be 1. This is because remainingSeconds will be calculated as seconds % 60, which will be 61 % 60 = 1. Therefore, pad(1) will be called for the last time in this program.
32
36
33
37
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
34
38
// =============> write your answer here
39
+
// The return value of pad when it is called for the last time with num equal to 1 will be "01". This is because pad uses the padStart method to convert the number to a string and pads it with leading zeros until it reaches a length of 2. Therefore, pad(1) will return "01".
0 commit comments