Skip to content

Commit c81c5df

Browse files
committed
Answer questions
1 parent ca2e82e commit c81c5df

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function formatTimeDisplay(seconds) {
1414

1515
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1616
}
17+
console.log(formatTimeDisplay(61))
1718

1819
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1920
// to help you answer these questions
@@ -22,17 +23,26 @@ function formatTimeDisplay(seconds) {
2223

2324
// a) When formatTimeDisplay is called how many times will pad be called?
2425
// =============> write your answer here
26+
// Answer to a) : when "formatTimeDisplay" is called "pad" is called 3 times
2527

2628
// Call formatTimeDisplay with an input of 61, now answer the following:
2729

2830
// b) What is the value assigned to num when pad is called for the first time?
2931
// =============> write your answer here
32+
// Answer to b) : value assigned to num when pad is called for the first time is 0 - zero
3033

3134
// c) What is the return value of pad is called for the first time?
3235
// =============> write your answer here
36+
// Answer to c) : the return value on pad is the "numString" variable, which is string "00"
3337

3438
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3539
// =============> write your answer here
40+
// Answer to d) : Value assigned to "num" the last time "pad" is called is 1, one.
41+
// "num" in this case is a variable "remainingSeconds", which is a remainder of "seconds" (61)
42+
// variable divided by 60, which is 1.
3643

3744
// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
3845
// =============> write your answer here
46+
// Answer to e) : The return value of "pad" the last time pad called is the variable "numString"
47+
// which is - string "01". "toString" variable is a "num" converted to a string earlier in the function
48+
// and makes it double digit string.

0 commit comments

Comments
 (0)