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
+12-3Lines changed: 12 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -22,15 +22,24 @@ console.log(formatTimeDisplay(61)); // This line is inserted only to test the fu
22
22
// =============> write your answer here
23
23
//3 times
24
24
// Call formatTimeDisplay with an input of 61, now answer the following:
25
-
// 00:01:01
25
+
26
26
// b) What is the value assigned to num when pad is called for the first time?
27
27
// =============> write your answer here
28
28
//61
29
29
// c) What is the return value of pad is called for the first time?
30
30
// =============> write your answer here
31
-
31
+
//0
32
32
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
33
33
// =============> write your answer here
34
-
34
+
/*
35
+
The value assigned to num when pad is called for the last time is 1.
36
+
The last call to pad in the template literal is pad(remainingSeconds). Since remainingSeconds = 61 % 60 = 1, the value passed to num is 1. This will return "01" after padding, resulting in the final output "00:01:01"
37
+
*/
35
38
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
36
39
// =============> write your answer here
40
+
/*
41
+
The return value of the last call to pad is "01".
42
+
Explanation: When pad is called with remainingSeconds (which equals 1), the parameter num receives the value 1. The function then converts it to a string "1",
43
+
pads it to 2 characters with leading zeros to get "01", and returns this string. This returned value "01"
44
+
is then inserted into the template literal as the last part of the time display, producing the final output "00:01:01".
0 commit comments