Conversation
…ory implement and mandatory interpret folders
✅ Deploy Preview for cyf-onboarding-module ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| console.log(capitalise("beautiful")); | ||
|
|
||
| // =============> write your explanation here | ||
| // function is assigned 2 arguments/values=============> write your explanation here |
There was a problem hiding this comment.
Please review the error message again and update the explanation. Think about what the error message is about and why it needs to be fixed.
| console.log(decimalNumber); | ||
|
|
||
| // =============> write your explanation here | ||
| // decimalNumber has been declared as a function and a variable within function scope=============> write your explanation here |
There was a problem hiding this comment.
decimalNumber is not a function.
Please review the explanation again and think about the following question and finally update the explanation.
- how is a function declaration different than a variable?
- what are function arguments and parameters?
- can a function variable and parameter have the same name?
| // Syntax errorError Unexpected number.=============> write the error message here | ||
|
|
||
| // =============> explain this error message here | ||
| // Means Function identifier should be a name not a number =============> explain this error message here. |
There was a problem hiding this comment.
Whats the difference between function identifier and parameter?
There was a problem hiding this comment.
I think you're confused between the function identifiers, parameters and arguments.
please review the following and update the explanation.
There was a problem hiding this comment.
That's right now, and the fix on line 23 too. Well done for sticking with this one.
|
|
||
| // =============> write your explanation here | ||
|
|
||
| //The 2nd console log returned value value is undefined. I have added a return function to output the multiply value. |
There was a problem hiding this comment.
why was the value returned by the function is undefined?
| console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
|
|
||
| // =============> write your explanation here | ||
| // Maybe that unassigned return; may cause the code not to run fully =============> write your explanation here |
There was a problem hiding this comment.
When you don't understand how or why a particular part of the code works or behaves in a certain way, it's best to dig a little deeper so you can build a solid understanding of it.
Please review the following MDN documentation on the return statement to help you understand how function returns work:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
| // return the BMI of someone based off their weight and height | ||
| } | ||
|
|
||
| function calculateBMI(weight, height) { |
There was a problem hiding this comment.
pleaser review the formula for calculating the BMI in the description above again.
| // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase | ||
|
|
||
| function toUpperSnakeCase(text) { | ||
| return text.trim().replace(/\s+/g, "_").toUpperCase(); |
There was a problem hiding this comment.
is there a need to use trim and regex pattern here? is there an easy of achieving this without using them?
| console.log(`£${pounds}.${pence}`);*/ | ||
|
|
||
| // Revised code: | ||
| function poundsToPence(penceString) { |
|
|
||
| // c) What is the return value of pad when it is called for the first time? | ||
| // =============> write your answer here | ||
| 0; |
| // Syntax errorError Unexpected number.=============> write the error message here | ||
|
|
||
| // =============> explain this error message here | ||
| // Means Function identifier should be a name not a number =============> explain this error message here. |
There was a problem hiding this comment.
I think you're confused between the function identifiers, parameters and arguments.
please review the following and update the explanation.
|
|
||
| function calculateBMI(weight, height) { | ||
| // return (weight / height).toFixed(1); - 1st attempt | ||
| return (weight / (height * height)).toString().slice(0, 4); |
There was a problem hiding this comment.
thats the correct formula now, however do you need to use .toString() and .slice() for getting fixed decimal points? is there an easier way of doing it without converting the value to string?
There was a problem hiding this comment.
Nearly there, toFixed(1) is the right tool. Run the file and you'll see both lines print ${(weight / (height * height)).toFixed(1)} as plain text. That's because ${} only works inside backticks (`), not double quotes.
You don't need ${} here at all, because toFixed(1) already gives back a string. What happens if you remove the quotes and the ${ } and return the calculation on its own?
| console.log(text); | ||
|
|
||
| // Trim and regex pattern was the only saving grace I came across to resolve the underscore issue I had spent hours researching. | ||
| // I have however now modified and replaced the pattern for easy understanding with AI's help |
There was a problem hiding this comment.
I appreciate your transparency. Using AI as a tool for research and to help clarify concepts you're struggling with is absolutely fine. You can find further guidance on the appropriate use of AI in the document below.
abdishakoor-dev
left a comment
There was a problem hiding this comment.
Good progress: 1-key-errors/2.js is right now, and line 15 explains the parameter clearly. You're close on the rest. Four things left, and each one is a small change:
1-key-errors/0.jsand1.js: put the original code in comments so your new code can run. See my comment on0.jsline 19.1-key-errors/1.jsline 32: log the result of calling your function.1-bmi.js: the quotes on line 24 (see my reply in the earlier thread), and the height on line 27.time-format.jsline 43: one word to fix in the explanation for e).
Add the Needs Review label again once you've pushed.
| // =============> write your explanation here | ||
| // =============> write your new code here | ||
|
|
||
| function capitalise(str) { |
There was a problem hiding this comment.
Your new code here is right, but it never runs. Try it: right click the 1-key-errors folder in VS Code, choose Open in Integrated Terminal, and run node 0.js. You'll see the SyntaxError from line 8. The original code on lines 7 to 11 still runs first, and JavaScript stops at the first error.
Select lines 7 to 11 and press Ctrl + / (Cmd + / on a Mac) to turn them into comments. Run node 0.js again and you should see Beautiful.
Do the same in 1.js for lines 9 to 16.
| } | ||
| const decimalNumber = 0.5; | ||
|
|
||
| console.log(decimalNumber); |
There was a problem hiding this comment.
After you comment out the original code, this line prints 0.5. That's the number going in, not the answer. The function's job is to turn 0.5 into 50%, so log what the function gives back: console.log(convertToPercentage(...)), with your number inside the brackets. You should see 50%.
| return "${(weight / (height * height)).toFixed(1)}"; | ||
| } | ||
|
|
||
| console.log(`the bmi of 70 and 2.99 is ${calculateBMI(70, 2.99)}`); |
There was a problem hiding this comment.
Your function needs the height, not the height squared. Line 7 shows the person is 1.73 m tall; 2.99 is what you get after squaring it. Your function already does the squaring on line 24, so pass 1.73. calculateBMI(70, 1.73) should print 23.4, the same as line 9. Checking against the example you were given is a good habit.
|
|
||
| // 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 | ||
| // The answer is 01 because of the final output for formatTimeDisplay(61) is 00:01:01. The assigned value of 1 with the length of 1, the numString = "0" + numString becomes 1 |
There was a problem hiding this comment.
Your answer 01 is right, only the last word needs fixing. On the last call numString is "1", which has length 1, so the loop runs once and "0" + "1" gives "01". So numString becomes "01", not 1.

Self checklist
Task code
CYF-1053
Changelist
02/09 - Updated files from the last run
30/09 - Corrected issues from run 1
I have updated all Sprint-3 files in the key errors, mandatory debug, mandatory implement and mandatory interpret folders