Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Millena28
Copy link

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@Millena28 Millena28 added the Needs Review Participant to add when requesting review label Dec 16, 2024
@Millena28 Millena28 changed the title Millena/Mesfin/Module-Dta-Groups/Sprint-1 Millena/Mesfin/Module-Data-Groups/Sprint-1 Dec 16, 2024
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The code in median.js is not quite correct.
  2. 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)];
Copy link
Contributor

@cjyuan cjyuan Dec 17, 2024

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);
}
Copy link
Contributor

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
}

Copy link
Contributor

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]);

@cjyuan cjyuan added 👀 Review Requirements Changes requested to meet requirements Reviewed Volunteer to add when completing a review and removed Needs Review Participant to add when requesting review labels Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👀 Review Requirements Changes requested to meet requirements Reviewed Volunteer to add when completing a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants