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 24 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.
| 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?
| 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.| function upperSnakeCase(wordsSet) { | ||
| let wsSnakeCase = wordsSet.replaceAll(" ", "_"); | ||
| let wsupperSnakeCase = wsSnakeCase.toUpperCase(); | ||
| return console.log(wsupperSnakeCase); | ||
| } |
There was a problem hiding this comment.
Accordingly to the description on lines 9-10, the function is expected to return the converted value, not output the converted value to the console.
Learners, PR Template
Self checklist
Changelist
complete sprint 2 mandatory tasks
Questions