Skip to content

Commit 4a52872

Browse files
committed
Understanding of Pad and formatTimeDisplay functions
1 parent a396ade commit 4a52872

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎Sprint-3/4-mandatory-interpret/time-format.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,22 @@ function formatTimeDisplay(seconds) {
2222

2323
// a) When formatTimeDisplay is called how many times will pad be called?
2424
// =============> write your answer here
25+
// 3 times
2526

2627
// Call formatTimeDisplay with an input of 61, now answer the following:
2728

2829
// b) What is the value assigned to num when pad is called for the first time?
2930
// =============> write your answer here
31+
// 0
3032

3133
// c) What is the return value of pad when it is called for the first time?
3234
// =============> write your answer here
33-
35+
// string "00"
3436
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3537
// =============> write your answer here
36-
38+
// remainingSeconds is 1, the last pad will execute so the function will divide 61 by 60 and then return the modulus or remainder which is 1.
3739
// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
3840
// =============> write your answer here
41+
// "01", The pad function recieves the number 1 and converts it to a number string.
42+
// The while loop checks the string length to get 1. 1 is less than 2 therefore the loop executes and adds a 0 to the string giving "01".
43+
// The loop will finishes because 2 is not less than 2. The function returns "01"

0 commit comments

Comments
 (0)