Sheffield| 26-ITP-Jan| Mona-Eltantawy | Sprint 2 | Coursework/sprint 2#1227
Sheffield| 26-ITP-Jan| Mona-Eltantawy | Sprint 2 | Coursework/sprint 2#1227Mona-Eltantawy wants to merge 13 commits intoCodeYourFuture:mainfrom
Conversation
…syntax error occurs when the program runs and write the new code that doesn't redeclare the decimalNumber in a const variable in inside the function
…e the function paramater name is unvaild number . and changed the code after trying it by changing the function name to num be decalred and to work when I call the function.
… return a value and changed the console.log inside the function into return instead.
…return statement comes befor the value a +b and changed it to the correct order.
…amater to the getLastDigit function to make it accept new paramaters when it's called.
…underscores using the .toUpperCase() and 'replace' functions.
…ing and added a return at the end of the function.
…n of the str identifier and this what happened when i tested the programe. I suggested to change the let variable name into an new name 'newStr' and this fixed the issue.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| // =============> write your explanation here | ||
| // =============> write your explanation here | ||
| when the program run it give a SyntaxError: Identifier 'decimalNumber' has already been declared. This is because the variable decimalNumber is declared twice in the function | ||
| convertToPercentage, and inside the function with the constant varible it redeclared again also using the function name decimalNumber with the console.log function will give an error because the function name should be |
There was a problem hiding this comment.
This sentence is quite long, and without punctuation marks it is not easy to read. Can you revise it?
| when the program run it give a SyntaxError: Identifier 'decimalNumber' has already been declared. This is because the variable decimalNumber is declared twice in the function | ||
| convertToPercentage, and inside the function with the constant varible it redeclared again also using the function name decimalNumber with the console.log function will give an error because the function name should be | ||
| to fix this error we can remove the const variable declaration of decimalNumber from the function and use the function name | ||
| 'ConvertToPercentage' to recall the function and pass the value of the decimalNumber.CSSStyleDeclaration |
There was a problem hiding this comment.
.CSSStyleDeclaration: What is this?
| while the ouout the out put for the console.log function out of the function returned the string provided in the function and an undefiened because the function multibly doesn't return any value. | ||
| to fix this error we need to change the console.log function inside the multiply function to return. |
There was a problem hiding this comment.
You have probably figured out the bug, but I can't quite get what this sentence mean.
|
|
||
| function calculateBMI(weight, height) { | ||
| let BMI = weight / (height ** 2); | ||
| return BMI.toFixed(1); |
There was a problem hiding this comment.
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?
Different types of values may appear identical in the console output, but they are represented and treated differently in the program. For example,
console.log(123); // Output 123
console.log("123"); // Output 123
// Treated differently in the program
let sum1 = 123 + 100; // Evaluate to 223 -- a number
let sum 2 = "123" + 100; // Evaluate to "123100" -- a string.| function toPounds(penceString) { | ||
| const penceStringWithoutTrailingP = penceString.substring( | ||
| 0, | ||
| penceString.length - 1 | ||
| ); | ||
|
|
||
|
|
||
| const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); | ||
| const pounds = paddedPenceNumberString.substring( | ||
| 0, | ||
| paddedPenceNumberString.length - 2 | ||
| ); | ||
|
|
||
| const pence = paddedPenceNumberString | ||
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); | ||
| return `£${pounds}.${pence}`; | ||
| } |
There was a problem hiding this comment.
Indentation is off.
Have you installed the prettier VSCode extension and enabled "Format on save/paste" on VSCode,
as recommended in
https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/blob/main/readme.md
?
Self checklist
Changelist
I did the required changes for the Sprint 2 key -errors, mandatory-debug, mandatory- implement and mandatory- interpret files. committed the changes and pushed it to the git branch.