London | ITP-may-2026 | Hugh Mills | Sprint 2 | Sprint 2 Coursework - #1515
London | ITP-may-2026 | Hugh Mills | Sprint 2 | Sprint 2 Coursework#1515HM-127BTY wants to merge 13 commits into
Conversation
Answered questions.
Added answers to questions.
Added answers to the questions
Added answers to the questions.
added answer to questions asked.
Added answers to the questions asked.
Added code for the bmi calculator,
Completed the code required for the task.
Added the simple code for converting to pounds, using kilograms.
Answered questions required.
| function convertToPercentage(decimalNumber) { | ||
| const decimal = 0.5; | ||
| const percentage = `${decimal * 100}%`; | ||
|
|
||
| return percentage; | ||
|
|
||
| } | ||
| console.log(convertToPercentage) |
There was a problem hiding this comment.
How would you make the function to work for any valid argument?
For example, calling convertToPercentage(0.1) would return "10%".
There was a problem hiding this comment.
Like this?
function convertToPercentage(decimalNumber) {
return percentage = ${decimalNumber * 100}%;
There was a problem hiding this comment.
Correct.
Do lookup Markdown syntax for embedding code.
| function UpperSnake(text) { | ||
| let upperCase = text.toUpperCase(); | ||
| let snakeCase = upperCase.replaceAll(" ","_"); | ||
| return snakeCase; | ||
| } |
There was a problem hiding this comment.
Code is correct.
Can you look up the naming conventions in JavaScript? In particular,
- Variable and function names
Then, update the function names according to those conventions.
There was a problem hiding this comment.
Not to sure what you mean with this one?
There was a problem hiding this comment.
What's best practice to name a function in JavaScript?
There was a problem hiding this comment.
The name should describe clearly what the function is doing.
There was a problem hiding this comment.
so I should have named it more like upperCase => makeUpperCase and snakeCase => makeSnakeCase ?
There was a problem hiding this comment.
Yes. A to prefix also works.
| function toPounds(weight) { | ||
| return (weight * 2.204); | ||
| } |
There was a problem hiding this comment.
You are supposed to use the code in Sprint-1/3-mandatory-interpret/3-to-pounds.js to implement this function.
There was a problem hiding this comment.
I see my mistake there, I did fix the error and copy the code in and done the adjustments.
| // b) What is the value assigned to num when pad is called for the first time? | ||
| // =============> write your answer here | ||
| // =============> 61 | ||
|
|
||
| // c) What is the return value of pad is called for the first time? | ||
| // =============> write your answer here | ||
| // =============> "61" |
There was a problem hiding this comment.
When pad() is called the first time, its parameter num is not 61.
There was a problem hiding this comment.
I see now, i put in the value not what it became when num was called making it 0 for the first and 00 for the return.
|
|
||
| // 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 | ||
| // =============> 1 at const remainingSexonds = seconds % 60 gives 1 No newline at end of file |
There was a problem hiding this comment.
What does pad() return when its parameter num is 1?
There was a problem hiding this comment.
I see my error, it should be 01
…reated code to pounds (weight) and copied in code from sprint 1 to make adjustments.
Learners, PR Template
Self checklist
Changelist
Completed the questions asked and added in code required for each task.