Skip to content

Commit e4bb558

Browse files
author
russom
committed
Answer and explain how code works
1 parent 7b9c2e2 commit e4bb558

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 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
@@ -23,16 +24,27 @@ function formatTimeDisplay(seconds) {
2324
// a) When formatTimeDisplay is called how many times will pad be called?
2425
// =============> write your answer here
2526

27+
// pad is called 3 times.
28+
2629
// Call formatTimeDisplay with an input of 61, now answer the following:
2730

2831
// b) What is the value assigned to num when pad is called for the first time?
2932
// =============> write your answer here
3033

34+
// The value that assigned to num is 0
35+
3136
// c) What is the return value of pad when it is called for the first time?
3237
// =============> write your answer here
3338

39+
// The return value of pad is: "00"
40+
3441
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3542
// =============> write your answer here
3643

44+
// The value assigned to num is 1. This is because 1 is the last character in the string 61
45+
3746
// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
3847
// =============> write your answer here
48+
49+
// The return value is "01". when pad is called for the last time it takes the last character of the string 61.
50+
// After checking remainingSeconds length which is less than 2 it adds a "0" and returns "01"

0 commit comments

Comments
 (0)