@@ -11,24 +11,31 @@ function formatTimeDisplay(seconds) {
1111 return `${ pad ( totalHours ) } :${ pad ( remainingMinutes ) } :${ pad ( remainingSeconds ) } ` ;
1212}
1313
14+ console . log ( formatTimeDisplay ( 61 ) ) ;
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?
2021// =============> write your answer here
22+ // The function pad will be called 3 times.
2123
2224// Call formatTimeDisplay with an input of 61, now answer the following:
2325
2426// b) What is the value assigned to num when pad is called for the first time?
2527// =============> write your answer here
28+ // the value is 0
2629
2730// c) What is the return value of pad is called for the first time?
2831// =============> 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
2934
3035// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3136// =============> 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
3238
3339// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
3440// =============> 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