-
-
Notifications
You must be signed in to change notification settings - Fork 153
Millena/Mesfin/Module-Data-Groups/Sprint-1 #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The code in
median.js
is not quite correct. - The Jest unit tests are not specified in
sum.test.js
.
Besides these, all code looks good.
I also left some comments and questions to challenge your understanding.
I left the following suggestion in sum.test.js
in most PRs. So I will go ahead and leave them here to help you prepare the tests in sum.test.js
.
Decimal numbers in most programming languages (including JS) are internally represented in "floating point number" format. Floating point arithmetic is not exact. For example, the result of 46.5678 - 46 === 0.5678
is false because 46.5678 - 46
only yield a value that is very close to 0.5678
.
So expect(sum([1.1, 1.1, 1.1])).toEqual(3.3);
would probably fail.
Can you find a more appropriate way to test a value (that involves decimal number calculations) for "equality?
@@ -1 +1,7 @@ | |||
function dedupe() {} | |||
function dedupe(arr) { | |||
return [...new Set(arr)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain how [...new Set(arr)]
is able to create an array with no duplicates from arr
?
|
||
// Find and return the maximum number in the numeric elements | ||
return Math.max(...numericElements); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you expect from the following function calls (on extreme cases)?
Does your function return the value you expected?
findMax([-Infinity])
findMax([-Infinity, 0])
findMax(["123", 45])
findMax([0, NaN, 1])
.filter((element) => typeof element === "number") | ||
.reduce((acc, num) => acc + num, 0); // Start with 0 as the initial sum | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you expect from the following function calls (on extreme cases)?
Does your function return the value you expected?
sum([NaN, 1]);
sum([Infinity, -Infinity]);
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.