London | 26-ITP-January | Khaliun Baatarkhuu | Sprint 2 | Coursework. #1143
London | 26-ITP-January | Khaliun Baatarkhuu | Sprint 2 | Coursework. #1143khaliun-dev wants to merge 10 commits intoCodeYourFuture:mainfrom
Conversation
Updated variable name to avoid redeclaration error.
Removed redeclaration of decimalNumber and updated console.log to call the function.
Corrected the square function to use a valid parameter name and return the square of the input.
…g the result. Changed console.log to return in multiply function to fix undefined error.
Corrected the sum function to return the sum of two numbers instead of undefined.
Updated the getLastDigit function to accept a parameter and removed unused variable.
Implement BMI calculation and log result.
Add function to convert string to upper snake case
…ock of code. Implemented the toPounds function to convert pence to pounds.
|
|
||
| // =============> write your explanation here | ||
| // =============> write your new code here | ||
| //Above code works because we have used another variable "newStr", avoiding redeclaration. |
There was a problem hiding this comment.
This is good. But do you think there could be another way to do this? One that doesn't require you to declare any variables at all?
There was a problem hiding this comment.
function capitalise(str) {
return str[0].toUpperCase() + str.slice(1);
}
Could this work? Just by removing the unnecessary variable?
| const decimalNumber = 0.5; | ||
| const percentage = `${decimalNumber * 100}%`; | ||
|
|
||
| return percentage; |
There was a problem hiding this comment.
This is good. But do you think there could be another way to do this? One that doesn't require you to declare any variables at all?
There was a problem hiding this comment.
function convertToPercentage(decimalNumber) {
return ${decimalNumber * 100}%;
}
console.log(convertToPercentage(0.5));
|
|
||
| function calculateBMI(weight, height) { | ||
| function calculateBMI(weight, height) { | ||
| const bmi = weight / (height * height); |
There was a problem hiding this comment.
There's a division here. Do you think we need to put in any specific safety guards?
There was a problem hiding this comment.
We should guard against height being 0 so we could add the following guard:
if (height <= 0) {
return "Height must be greater than 0";
}
There was a problem hiding this comment.
@ykamal I think i have fixed all three problems you have raised, could you please have another look?
Self checklist
Changelist
Questions
None at the moment.