-
-
Notifications
You must be signed in to change notification settings - Fork 546
London | 26 ITP SEP | Russom Gebremeskel | Sprint 3 | Coursework #1520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1df46e8
f00caed
507f02a
6f4e46f
9aadee0
6018cd5
444757f
8245202
4064cd8
2bdebf4
849b970
c3b0ad5
0f95d9b
7b9c2e2
e4bb558
3eee2ad
6bece94
5eba71d
8ecde42
8c33243
7d6f51d
db95486
70e2b1b
47cee31
a7d328c
21c9992
172a529
b0d0f7c
f39cb79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ function formatTimeDisplay(seconds) { | |
|
|
||
| return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; | ||
| } | ||
| console.log(formatTimeDisplay(61)) | ||
|
|
||
| // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit | ||
| // to help you answer these questions | ||
|
|
@@ -23,16 +24,27 @@ function formatTimeDisplay(seconds) { | |
| // a) When formatTimeDisplay is called how many times will pad be called? | ||
| // =============> write your answer here | ||
|
|
||
| // pad is called 3 times. | ||
|
|
||
| // Call formatTimeDisplay with an input of 61, now answer the following: | ||
|
|
||
| // b) What is the value assigned to num when pad is called for the first time? | ||
| // =============> write your answer here | ||
|
|
||
| // The value that assigned to num is 0 | ||
|
|
||
| // c) What is the return value of pad when it is called for the first time? | ||
| // =============> write your answer here | ||
|
|
||
| // The return value of pad is: "00" | ||
|
|
||
| // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer | ||
| // =============> write your answer here | ||
|
|
||
| // The value assigned to num is 1. This is because 1 is the last character in the string 61 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value 1 is right, but have another look at why.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 61 % 60 is 61 divided by 60 which is 1(totalMinutes) and the leftover 1 assigned to remainingSeconds |
||
|
|
||
| // e) What is the return value of pad when it is called for the last time in this program? Explain your answer | ||
| // =============> write your answer here | ||
|
|
||
| // The return value is "01". when pad is called for the last time it takes the last character of the string 61. | ||
| // After checking remainingSeconds length which is less than 2 it adds a "0" and returns "01" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things here. The task asks for a function called
toPoundsand this one istoPound. And it says to call it a number of times to check it works for different inputs, where there is only the one call with"399p". What else would you try it with?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it with: 0, 00, 000, 01, 9, 58749 ...