London | 25-ITP-SEP | Sophia Mohamed | Sprint 2 | coursework/sprint-2 #803
London | 25-ITP-SEP | Sophia Mohamed | Sprint 2 | coursework/sprint-2 #803saff-coder wants to merge 12 commits intoCodeYourFuture:mainfrom
Conversation
London | 25-ITP-Sept | Sophia Mohamed | Sprint 1 | coursework/sprint-1
The codes are fixed, the error has been corrected and explained
The prediction and explanation were done
1. Calculating the BMI 2. Change a sentence from lowercase to uppersnake case 3. Changing from Kg to lb
I run the code in Python Visualiser and answered all the questions
cjyuan
left a comment
There was a problem hiding this comment.
This branch is not clean -- It includes changes in the Sprint-1 folder (which is not related to Sprint-2 exercise). Can you revert the changes made in the Sprint-1 folder?
This reverts commit 7312985.
|
I reverted the commit from sprint 1 |
cjyuan
left a comment
There was a problem hiding this comment.
Good job in reverting the changes made in Sprint-1 folder.
| let bmi = 85 / (1.54 * 1.54); | ||
| console.log(bmi) | ||
| //here the result was 35.833307439446366 I need to round it to 1 decimal place | ||
| console.log(bmi.toFixed(1)); | ||
| //now the output is 35.8 |
There was a problem hiding this comment.
The objective of this exercise is to complete the implementation of the function calculateBMI() so that we can reuse the code in the function to calculate BMI for different weight and height.
| const pounds = kg * 2.20462; | ||
|
|
||
| return pounds; |
There was a problem hiding this comment.
This toPounds() function is supposed to convert a pence string to a string in British pounds format, like what you did in Sprint-1/3-mandatory-interpret/3-to-pounds.js
There was a problem hiding this comment.
I have updated the code as required
This function converts the weight in kg to pounds
| const bmi = weight / (height * height); | ||
|
|
||
| // Round to 1 decimal place and return | ||
| return bmi.toFixed(1); |
There was a problem hiding this comment.
Both of these function calls output 123 in the console, but internally in the program,
the number 123 and the string "123" are stored and treated differently.
console.log(123);
console.log("123");What type of value do you expect your function to return? A number or a string?
Does your function return the type of value you expect?
There was a problem hiding this comment.
I expect the function to return a number, because a BMI is a numeric value. Yes, I tested the function, and it comes as a number.
There was a problem hiding this comment.
How did you test if its return value is a number and not a string?
There was a problem hiding this comment.
That's not a proper way to check the type of a value.
Can you ask AI (and then verify if needed) how to determine the type of a value in JS?
There was a problem hiding this comment.
Thank you so much, that was really helpful. I used (type of )and it showed me that my output was a string, and I changed it to a number
| const pounds = kg * 2.20462; | ||
| return `${pounds.toFixed(2)} lbs`; // returns a string |
There was a problem hiding this comment.
This is still not what is expected.
There was a problem hiding this comment.
I have changed the code, and the output is a number, not a string
There was a problem hiding this comment.
This function is supposed to convert pence to British pounds (similar to what you did in Sprint-1/3-mandatory-interpret/3-to-pounds.js
There was a problem hiding this comment.
I think this question is to convert the weight from kilograms to Pounds, not British pounds
There was a problem hiding this comment.
What makes you think that? What does the comments (lines 1-60 in the file say?
There was a problem hiding this comment.
Thank you so much for all your help
I was able to test my data type using typeof
|
Changes look good. You forgot to change the label. |

Learners, PR Template
Self checklist
Changelist
Completed all the exercises in Sprint-2