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
+8-5Lines changed: 8 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -21,18 +21,21 @@ function formatTimeDisplay(seconds) {
21
21
// Questions
22
22
23
23
// a) When formatTimeDisplay is called how many times will pad be called?
24
-
// =============> write your answer here
24
+
// =============> It would be called 3 times, that is for hours, minutes and seconds.
25
25
26
26
// Call formatTimeDisplay with an input of 61, now answer the following:
27
27
28
28
// b) What is the value assigned to num when pad is called for the first time?
29
-
// =============> write your answer here
29
+
// =============> The answer would be '0' because the first time pad is called, relates to the hours remaining.
30
30
31
31
// c) What is the return value of pad is called for the first time?
32
-
// =============> write your answer here
32
+
// =============> It would return '00' because the value of num 0 is converted to a string "0", since its length is less than two the pad function adds a "0" to the front to output "00".
33
33
34
34
// 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
35
+
// =============> The answer is 1.
36
+
//explanation: the last time pad is called is for the remaining seconds, which would return 1 because we passed 61 into the program, calculated as 61 % 60.
36
37
37
38
// 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
39
+
// =============> Answer "01".
40
+
// Explaination: The return value of pad when it is called for the last time in this program is '01'. This is because the value of num is 1 (the remaining seconds after calculating 61 % 60).
41
+
// Since the length of the string representation of 1 is less than 2, the pad function adds a "0" to the front, resulting in "01".
0 commit comments