Skip to content

Commit ead2f59

Browse files
committed
time-format.js has been solved
1 parent b0b0990 commit ead2f59

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,33 @@ function pad(num) {
33
}
44

55
function formatTimeDisplay(seconds) {
6-
const remainingSeconds = seconds % 60;
6+
const remainingSeconds = seconds % 60;
77
const totalMinutes = (seconds - remainingSeconds) / 60;
88
const remainingMinutes = totalMinutes % 60;
99
const totalHours = (totalMinutes - remainingMinutes) / 60;
1010

1111
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1212
}
13+
console.log(formatTimeDisplay(61));
1314

1415
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1516
// to help you answer these questions
1617

1718
// Questions
1819

1920
// a) When formatTimeDisplay is called how many times will pad be called?
20-
// =============> write your answer here
21+
// =============> Three time
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?
25-
// =============> write your answer here
26+
// =============> num =0
2627

2728
// c) What is the return value of pad is called for the first time?
28-
// =============> write your answer here
29+
// =============> return value='00'
2930

3031
// 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
32+
// =============> num=1 because it will take the value of remainingseconda which is 1;
3233

3334
// 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
35+
// =============> return value ='01' it will take number 1 then will convert to sting then it will add 0 to the first because it is only one character .

0 commit comments

Comments
 (0)