London | 26-ITP-Jan | Boualem Larbi Djebbour | sprint 2 | Coursework#1123
London | 26-ITP-Jan | Boualem Larbi Djebbour | sprint 2 | Coursework#1123djebsoft wants to merge 28 commits intoCodeYourFuture:mainfrom
Conversation
Corrected variable declaration issue and updated function to return the capitalized string.
…ge function Removed duplicate declaration of decimalNumber and updated the function to correctly convert a decimal to a percentage.
Corrected the square function to accept a parameter and return its square.
Refactor multiply function to return result and log output.
Corrected the sum function to return the sum of two numbers.
Corrected the getLastDigit function to accept a parameter and return the last digit of the given number.
Corrected the function getLastDigit to properly accept a parameter.
Added explanations and answers to questions regarding the pad function in time-format.js.
Implemented the toPounds function to convert pence to pounds.
Added a function to convert a string to upper snake case.
Sprint-2/2-mandatory-debug/0.js
Outdated
| function multiply(a, b) { | ||
| return console.log( | ||
| `The result of multiplying ` + a + ` and ` + b + ` is ` + a * b | ||
| ); | ||
| } |
There was a problem hiding this comment.
If there is a need to output the string in a fixed format from different "places" in the program, it would make sense to implement a function do so.
However, what is the purpose of returning the return value of console.log()? What value do you expect console.log() to return?
There was a problem hiding this comment.
we just actually need the function to pass the output to the next line of code after its destroyed
so we need the function to return what its statement evaluate to
There was a problem hiding this comment.
Not sure what you meant by "destroyed".
| function calculateBMI(weight, height) { | ||
| // return the BMI of someone based off their weight and height | ||
| } No newline at end of file | ||
| return (BMI = (weight / (height * height)).toFixed(1)); // return the BMI of someone based off their weight and height |
There was a problem hiding this comment.
-
What is BMI? Why not just return the value of the expression
(weight / (height * height)).toFixed(1)? -
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.There was a problem hiding this comment.
fixed the statement of the value returned
converted the string to a number
|
thank you for reviewing my work |
| function calculateBMI(weight, height) { | ||
| // return the BMI of someone based off their weight and height | ||
| } No newline at end of file | ||
| return Number(weight / (height * height)).toFixed(1); // return the BMI of someone based off their weight and height |
There was a problem hiding this comment.
How can you be sure that the function is returning a number and not a string?
There was a problem hiding this comment.
by adding the number() to the expression that contains strings
but after your comment I checked it using typeof and it turns out it's string
then I included the whole expression in the number() by adding parentheses, then it worked
but prettier didn't allow me to save the change so I made it in my github remote repository
| // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase | ||
| function upperSnakeCase(wordsSet) { | ||
| let wsSnakeCase = wordsSet.replaceAll(" ", "_"); | ||
| let wsupperSnakeCase = wsSnakeCase.toUpperCase(); |
There was a problem hiding this comment.
What do you think about this version:wsUpperSnakeCase? (No change needed)
There was a problem hiding this comment.
I think it could be shortened and embeded in the previous line
|
Changes are good. Well done. |
Learners, PR Template
Self checklist
Changelist
complete sprint 2 mandatory tasks
Questions