@@ -11,24 +11,31 @@ function formatTimeDisplay(seconds) {
11
11
return `${ pad ( totalHours ) } :${ pad ( remainingMinutes ) } :${ pad ( remainingSeconds ) } ` ;
12
12
}
13
13
14
+ console . log ( formatTimeDisplay ( 61 ) ) ;
14
15
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
15
16
// to help you answer these questions
16
17
17
18
// Questions
18
19
19
20
// a) When formatTimeDisplay is called how many times will pad be called?
20
21
// =============> write your answer here
22
+ // The function pad will be called 3 times.
21
23
22
24
// Call formatTimeDisplay with an input of 61, now answer the following:
23
25
24
26
// b) What is the value assigned to num when pad is called for the first time?
25
27
// =============> write your answer here
28
+ // the value is 0
26
29
27
30
// c) What is the return value of pad is called for the first time?
28
31
// =============> write your answer here
32
+ // # The Python visualizer stops working when it runs pad because (padStart is not a function), maybe because it uses ES6 version of javascript!
33
+ // The return value of pad when it's called for the first time is 00
29
34
30
35
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
31
36
// =============> write your answer here
37
+ //the value assigned to num is 1 . the value 1 is the number of the remaining seconds, pad() converted it to 01
32
38
33
39
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
34
40
// =============> write your answer here
41
+ // the return value is 01 . the function pad() converted num (which values 1) to 01 so the seconds can be readable easily.
0 commit comments