Skip to content

Commit 81cb5ed

Browse files
committed
complete 4-mandatory-interpret/time-format
1 parent fbfd66f commit 81cb5ed

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,32 @@ function formatTimeDisplay(seconds) {
1111
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1212
}
1313

14+
console.log(formatTimeDisplay(61));
15+
console.log(formatTimeDisplay(6671));
16+
console.log(formatTimeDisplay(832));
17+
1418
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1519
// to help you answer these questions
1620

1721
// Questions
1822

1923
// a) When formatTimeDisplay is called how many times will pad be called?
20-
// =============> write your answer here
24+
// =============> 3 times
2125

2226
// Call formatTimeDisplay with an input of 61, now answer the following:
2327

2428
// b) What is the value assigned to num when pad is called for the first time?
25-
// =============> write your answer here
29+
// =============> "0"
30+
// The first time, pad() is called with totalHours, which value is "0"
2631

2732
// c) What is the return value of pad is called for the first time?
28-
// =============> write your answer here
33+
// =============> "00"
34+
// pad() adds a "0" at the start of the string to make it 2 characters long
2935

3036
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
31-
// =============> write your answer here
37+
// =============> "1"
38+
// The last time, pad() is called with remainingSeconds, which value is "1"
3239

3340
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
34-
// =============> write your answer here
41+
// =============> 01
42+
// pad adds a "0" before "1" to make it 2 characters long

0 commit comments

Comments
 (0)