-
-
Notifications
You must be signed in to change notification settings - Fork 336
London | 26-ITP-Jan | Gloria Mankrado | sprint 2 | Coursework #1154
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
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,3 +14,8 @@ | |
| // You will need to come up with an appropriate name for the function | ||
| // Use the MDN string documentation to help you find a solution | ||
| // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase | ||
|
|
||
| function toUpperSnakeCase(str) { | ||
| return str.toUpperCase().replace(/ /g, '_'); | ||
| // return the string in UPPER_SNAKE_CASE | ||
| } | ||
|
Comment on lines
+17
to
+21
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. Is it best to pass in //g as an argument in your .replace method? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,8 @@ | |
| // You will need to declare a function called toPounds with an appropriately named parameter. | ||
|
|
||
| // You should call this function a number of times to check it works for different inputs | ||
|
|
||
| function toPounds(kilograms) { | ||
| return kilograms * 2.20462; | ||
| // return the weight in pounds | ||
| } | ||
|
Comment on lines
+7
to
+11
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. You should read the context of the task to understand what you are to do. The task is referring to the code from the previous sprint, which you are to work with to actualise the given task. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,17 +18,21 @@ function formatTimeDisplay(seconds) { | |
|
|
||
| // a) When formatTimeDisplay is called how many times will pad be called? | ||
| // =============> write your answer here | ||
| // The `pad` function will be called three times when `formatTimeDisplay` is called, once for each of the time components: hours, minutes, and seconds. Each component is passed to the `pad` function to ensure it is displayed with at least two digits, adding a leading zero if necessary. | ||
|
|
||
| // 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 | ||
| // When `formatTimeDisplay(61)` is called, the first time `pad` is called, `num` is assigned the value of `totalHours`, which is 0. | ||
|
|
||
| // c) What is the return value of pad is called for the first time? | ||
| // =============> write your answer here | ||
| // The return value of `pad(0)` 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 | ||
|
|
||
| // When `formatTimeDisplay(61)` is called, the last time `pad` is called, `num` is assigned the value of `remainingSeconds`, which is 1. | ||
| // e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer | ||
| // =============> write your answer here | ||
| // The return value of `pad(1)` is "01". | ||
|
Comment on lines
36
to
+38
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. You could further explain your reason for this answer by analysing the full output of the given code when the function is called with the passed in argument. |
||
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.
Is there a better method to return the bmi value in one decimal place?