Skip to content

Commit f54452f

Browse files
committed
Answer questions
1 parent b0260ef commit f54452f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

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

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

2323
// a) When formatTimeDisplay is called how many times will pad be called?
2424
// =============> write your answer here
25+
// 3
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
35+
// "00"
3336

3437
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3538
// =============> write your answer here
39+
// 1. Last time it is called is pad(remainingSeconds). remainingSeconds = seconds % 60
40+
// with seconds = 61 this expression evaluates to 1, so when 1 is passed to pad, num is
41+
// assigned 1.
3642

3743
// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
3844
// =============> write your answer here
45+
// "01". Num is 1 which converted to the string "1" which is assigned to numString.
46+
// The while loop runs while numString length less than 2, and adds "0"
47+
// to the beginning string. So "1" becomes "01". the string length is now equal to two,
48+
// so the while loop exits and numString is returned with value "01"

0 commit comments

Comments
 (0)