Skip to content

Commit 6493a42

Browse files
committed
Sprint-2, 4-mandatory-interpret done
1 parent bc71103 commit 6493a42

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,38 @@ function formatTimeDisplay(seconds) {
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 times:
22+
// pad(totalHours)
23+
// pad(remainingMinutes)
24+
// pad(remainingSeconds)
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 for totalHours
2630

2731
// c) What is the return value of pad is called for the first time?
28-
// =============> write your answer here
32+
// =============> 0 for totalHours, which is then converted to "00" by the padStart
33+
// method because the string length of "0" is less than 2
2934

3035
// 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
36+
// =============> 1 for remainingSeconds; it is the num parameter, not the string
3237

3338
// 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
39+
// =============> The string "01" because the string length of "1" is less than 2
40+
41+
// By the way - the Python visualiser didn't want to work with this. It said:
42+
// File "<string>", line 1
43+
// function pad(num) {
44+
// ^^^
45+
// SyntaxError: invalid syntax
46+
47+
// I asked Claude.ai to help instead

0 commit comments

Comments
 (0)