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
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -23,16 +23,26 @@ function formatTimeDisplay(seconds) {
23
23
// a) When formatTimeDisplay is called how many times will pad be called?
24
24
// =============> write your answer here
25
25
26
+
// pad will be called 3 times when formatTimeDisplay is called. Once for totalHours, once for remainingMinutes and one for remainingSeconds.
27
+
26
28
// Call formatTimeDisplay with an input of 61, now answer the following:
27
29
28
30
// b) What is the value assigned to num when pad is called for the first time?
29
31
// =============> write your answer here
30
32
33
+
// The value assigned to num when pad is called for the first time is 0. This is because totalHours is calculated as (totalMinutes - remainingMinutes) / 60, which results in 0 when the input is 61 seconds.
34
+
31
35
// c) What is the return value of pad is called for the first time?
32
36
// =============> write your answer here
33
37
38
+
// The return value of pad when it is called for the first time is 00. this is because the value of num is 0 and the pad function adds a 0 to the front of the string until the num characters has at least 2 characters.
39
+
34
40
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
35
41
// =============> write your answer here
36
42
43
+
//The value assigned to num when pad is called for the last time is 1. This is because the last call to pad is for remainingSeconds which is calculated as seconds % 60, the result of which is 1.
44
+
37
45
// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
38
46
// =============> write your answer here
47
+
48
+
// The return value of pad when it is called for the last time is 01. This is because the pad function adds a 0 to the front of the string if the characters of the string are less than 2.
0 commit comments