London | 26-ITP-Sep | Chandramani Gaire | Sprint 3 | Sprint 3 coursework - #1607
gaireprakash20-ops wants to merge 19 commits into
Conversation
✅ Deploy Preview for cyf-onboarding-module ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
… height squared to get the BMI. I also used the toFixed method to round the BMI to one decimal place.
gaireprakash20-ops
left a comment
There was a problem hiding this comment.
i do as per the instruction
abdishakoor-dev
left a comment
There was a problem hiding this comment.
Your time-format.js answers are all correct, and d) and e) explain why.
Six things before I can mark this Complete:
-
1-bmi.js: see my comment on line 23. -
1-key-errors/1.js: see my comment on line 18. -
2-cases.js: see my comment on line 17. -
3-to-pounds.js: see my comment on line 7. -
2-mandatory-debug/2.js: see my comment on line 29. -
Eight of your files fail Prettier. "My code is consistently formatted" is part of the style guide in your PR checklist. Prettier is the tool that does it for you. It formats your code to one agreed style, so a reviewer only sees the changes you meant to make.
Prettier comes with the CYF extension pack from onboarding. If you're not sure you have it, search for CodeYourFuture Extension Pack in VS Code Extensions: https://marketplace.visualstudio.com/items?itemName=CodeYourFuture.cyf-extension-pack
Then open each file you changed, right click, choose Format Document, and pick Prettier if VS Code asks. To format every time you save, follow the steps here: https://github.com/CodeYourFuture/Module-JavaScript-Fundamentals/blob/main/practical_guide.md
Add the Needs Review label again once you've pushed.
| const bmi = weight/squared_height; | ||
| return bmi.toFixed(1); | ||
| } | ||
| console.log(`The BMi of the person is ${calculateBMI(70,2.99)}`); |
There was a problem hiding this comment.
Your function is correct. The call on this line is not.
- Line 5: the person is 1.73m tall.
- Line 7: 2.99 is 1.73 x 1.73. So 2.99 is the height squared, not the height.
- Your function already squares the height on line 19.
So when you pass 2.99, it is squared twice. That is why you get 7.8.
Please pass the height, 1.73, instead of 2.99. Line 9 says the answer should then be 23.4. Update your comment on line 24 too.
There was a problem hiding this comment.
I put the value 1.73 instead of 2.99 and update the comment on line24.
There was a problem hiding this comment.
Fixed now. 23.4 is right. Good.
|
|
||
| // =============> write your explanation here | ||
|
|
||
| // while running this function is shows typeerror because decimal number variable is declared two times. |
There was a problem hiding this comment.
Your fixed code is correct. Only the error name on this line is wrong.
Line 18 says TypeError. But the original code gives a SyntaxError. The name decimalNumber is declared two times, and JavaScript does not allow that.
Please change "typeerror" on line 18 to "SyntaxError".
There was a problem hiding this comment.
i make a small correction type error into syntax error.
There was a problem hiding this comment.
That's the one. Good.
| // 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 touppercase(str){ |
There was a problem hiding this comment.
Your function works. It gives HELLO_THERE. Only the name needs to change.
The name should say what the function does:
touppercasesays: make the letters capital. That is only half of the job.- Your function also changes spaces to
_. Line 4 calls this UPPER_SNAKE_CASE. - So a better name is
toUpperSnakeCase.
Also, in JavaScript we write a name with more than one word like this: the first word is small, and each new word starts with a capital letter. For example, toUpperCase, not touppercase. This is called camelCase.
Please rename the function, and the call on line 20.
There was a problem hiding this comment.
change the function name from touppercase into toUpperSnakeCase.
There was a problem hiding this comment.
toUpperSnakeCase is the one. Good.
| // 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 toPound(penceString) { |
There was a problem hiding this comment.
Line 4 asks for a function called toPounds, with an s at the end. Your function is toPound, with no s. Please rename it, and the calls on lines 22 and 23.
There was a problem hiding this comment.
as per the instruction i changed the function name topounds from topound.
| // In this variable num is constant and there is no any declaration in function name. Due to this reasons result always be 3. | ||
| // Finally, correct the code to fix the problem | ||
| // =============> write your new code here | ||
| const num = 103; |
There was a problem hiding this comment.
Your function on line 31 has its own num parameter. So is the num on line 29 used? If not, please remove it.
There was a problem hiding this comment.
i comment the line 29 but does not removed it. for reading its should be easy
There was a problem hiding this comment.
The original code on line 9 already shows const num = 103; for reading. Line 29 is part of your new code, and your new code does not need it at all.
The CYF style guide, which you ticked in your PR checklist, says:
Once you have solved the problem, you should remove large sections of commented out code. When you (or someone else) are reading your code, you want to know only the important pieces.
https://curriculum.codeyourfuture.io/guides/reviewing/style-guide/
Please delete line 29.
…e console log to reflect the new function name
abdishakoor-dev
left a comment
There was a problem hiding this comment.
Thanks for the fixes. The BMI call, the SyntaxError answer and both function names are all right now.
Two things before I can mark this Complete:
-
2-mandatory-debug/2.jsline 29: see my reply there. -
Eight of your files still fail Prettier, the same as last time. Please do these steps for each file you changed:
- Open the file in VS Code.
- Right click in the file, and choose Format Document.
- If VS Code asks which formatter to use, choose Prettier.
- Save the file.
If you don't see Prettier, install the CodeYourFuture Extension Pack first: https://marketplace.visualstudio.com/items?itemName=CodeYourFuture.cyf-extension-pack
To have Prettier do this every time you save, follow the format on save steps here: https://github.com/CodeYourFuture/Module-JavaScript-Fundamentals/blob/main/practical_guide.md
Add the Needs Review label again once you've pushed.
gaireprakash20-ops
left a comment
There was a problem hiding this comment.
Remove the line 29 and formatted Prettier.
abdishakoor-dev
left a comment
There was a problem hiding this comment.
Thanks. Line 29 is gone now. Good.
One thing is left before I can mark this Complete. The same eight files still fail Prettier. Your last commit only changed 2-mandatory-debug/2.js. So the formatting did not reach GitHub.
Please try this with one file first, 2-cases.js:
- Open it in VS Code.
- Right click in the file, and choose Format Document.
- On line 18, the single quotes
' 'and'_'should change to double quotes. If nothing changes, Prettier is not running. Install the CodeYourFuture Extension Pack: https://marketplace.visualstudio.com/items?itemName=CodeYourFuture.cyf-extension-pack - Save the file. It now shows in Source Control with an M.
Then do the same for the other seven files. Commit and push.
Add the Needs Review label again once you've pushed.
gaireprakash20-ops
left a comment
There was a problem hiding this comment.
last of change and Prettier file Formatting

Self checklist
Task code
CYF-1053
Changelist
I am solving some functional problems related to JavaScript.