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
+
// The function pad will be called three times when formatTimeDisplay is called, once for each of; hours, minutes, and seconds.These are then passed as an argument to the pad function to ensure that they are displayed with two digits in the final output string.
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
+
// The value assigned to num when pad is called for the first time is the totalHours value, which is 0. The value of 61 seconds is only one minute and one second, any value that includes hours must be in excess of 3600 seconds.
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 is "00". This is because the totalHours value is 0, and when it is converted to a string and passed to the pad function, it will be padded with a leading zero to ensure that it has two digits, resulting in "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
+
// The value assigned to num when pad is called for the last time in this program is the remainingSeconds value, which is 1. This is because the input of 61 seconds results in 1 second remaining after accounting for the full minute.
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
+
//This value displayed with two digits in the final output string, resulting in "01".
0 commit comments