Skip to content

Commit 80f3a4f

Browse files
committed
Update comments in formatTimeDisplay function to provide detailed explanations for pad function calls
1 parent 3fee2c5 commit 80f3a4f

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

Sprint-2/4-mandatory-interpret/time-format.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,21 @@ function formatTimeDisplay(seconds) {
2121
// Questions
2222

2323
// 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.
2525

2626
// Call formatTimeDisplay with an input of 61, now answer the following:
2727

2828
// 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.
3030

3131
// 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".
3333

3434
// 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.
3637

3738
// 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

Comments
 (0)