Skip to content

Commit 08a4679

Browse files
author
kohanman
committed
Sprint 2 | Coursework 4.1
1 parent 4c88103 commit 08a4679

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
function pad(num) {
22
return num.toString().padStart(2, "0");
33
}
4-
54
function formatTimeDisplay(seconds) {
65
const remainingSeconds = seconds % 60;
76
const totalMinutes = (seconds - remainingSeconds) / 60;
@@ -10,6 +9,7 @@ function formatTimeDisplay(seconds) {
109

1110
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1211
}
12+
console.log(formatTimeDisplay(61));
1313

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

1919
// a) When formatTimeDisplay is called how many times will pad be called?
2020
// =============> write your answer here
21+
//3
2122

2223
// Call formatTimeDisplay with an input of 61, now answer the following:
2324

2425
// b) What is the value assigned to num when pad is called for the first time?
2526
// =============> write your answer here
27+
//0
2628

2729
// c) What is the return value of pad is called for the first time?
2830
// =============> write your answer here
31+
//0
2932

3033
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3134
// =============> write your answer here
35+
//000
3236

3337
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
3438
// =============> write your answer here
39+
//0

0 commit comments

Comments
 (0)