File tree Expand file tree Collapse file tree
Sprint-2/4-mandatory-interpret Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ function pad ( num ) {
2+ let numString = num . toString ( ) ;
3+ while ( numString . length < 2 ) {
4+ numString = "0" + numString ;
5+ }
6+ return numString ;
7+ }
8+
9+ function formatTimeDisplay ( seconds ) {
10+ const remainingSeconds = seconds % 60 ;
11+ const totalMinutes = ( seconds - remainingSeconds ) / 60 ;
12+ const remainingMinutes = totalMinutes % 60 ;
13+ const totalHours = ( totalMinutes - remainingMinutes ) / 60 ;
14+
15+ return `${ pad ( totalHours ) } :${ pad ( remainingMinutes ) } :${ pad ( remainingSeconds ) } ` ;
16+ }
17+
18+ // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
19+ // to help you answer these questions
20+
21+ // Questions
22+
23+ // a) When formatTimeDisplay is called how many times will pad be called?
24+ // =============> write your answer here
25+
26+ // Call formatTimeDisplay with an input of 61, now answer the following:
27+
28+ // b) What is the value assigned to num when pad is called for the first time?
29+ // =============> write your answer here
30+
31+ // c) What is the return value of pad is called for the first time?
32+ // =============> write your answer here
33+
34+ // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
35+ // =============> write your answer here
36+
37+ // e) What is the return value of pad when it is called for the last time in this program? Explain your answer
38+ // =============> write your answer here
You can’t perform that action at this time.
0 commit comments