Skip to content

London | May-2025 | Halimatou Saddiyaa | Module-Data-Groups | Sprint 1 #548

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 7 commits into
base: main
Choose a base branch
from

Conversation

Halimatou-saddiyaa
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 REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

I've ompleted the following coursework on Sprint 1 of the Module Data Groups:

  • Fix
  • Implement
  • Refactor

Please review my PR

Questions

Ask any questions you have for your reviewer.

@Halimatou-saddiyaa Halimatou-saddiyaa added 📅 Sprint 1 Assigned during Sprint 1 of this module Needs Review Participant to add when requesting review labels Jul 3, 2025
@a-robson a-robson added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Participant to add when requesting review labels Jul 15, 2025
Copy link

@a-robson a-robson left a comment

Choose a reason for hiding this comment

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

Overall this is really good. Your solutions are correct and all the tests pass. I will mark this as complete. I am leaving some comments which I hope are helpful. I can discuss or expand if you like.

Comment on lines 12 to 14
// Secondly, we need to implement a function that filter out non numeric values.
const numbers = list.filter((item) => typeof item === "number");

Choose a reason for hiding this comment

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

Excellent work. However there is an edge case that the tests don't require you to handle. You might want to look at the special NaN property and consider whether the code would work if this value appeared in one of the test arrays. As I say it is not required but might be something to watch out for in the future.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you, the code might not work with Nan as although it is a number it's not a valid numeric value for math operations.
I've corrected my function to include the case of NaN and added a test to check.

Comment on lines 1 to 10
function dedupe(array) {
const seen = new Set();
return array.filter((item) => {
if (seen.has(item)) {
return false;
}
seen.add(item);
return true;
});
}

Choose a reason for hiding this comment

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

Clever solution. Using a Set is the right approach in most de-duplication problems. However there are easier ways to populate a Set from an Array. Do you need to use the filter function at all?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, I don't need to use the filter function as I can directly use Set and populate it from an Array. I've corrected my code to reflect that.

Comment on lines +1 to 7
function findMax(arr) {
const numbers = arr.filter((item) => typeof item === "number");
if (numbers.length === 0) {
return -Infinity;
}
return Math.max(...numbers);
}

Choose a reason for hiding this comment

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

Excellent solution.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks

Comment on lines 1 to 8
function sum(arr) {
return arr.reduce((total, current) => {
if (typeof current === "number") {
return total + current;
}
return total;
}, 0);
}

Choose a reason for hiding this comment

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

This is good. However it would be more typical pattern to use filter then reduce rather than having your 'filtering' logic within the reduce function. Why do you think that pattern would be preferred?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, I think using filter then reduce will be preferred because it separates the two steps and the code is then easier to read and understand. I've updated my code to reflect that.

@a-robson a-robson added Complete Volunteer to add when work is complete and review comments have been addressed and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jul 15, 2025
@Halimatou-saddiyaa
Copy link
Author

Thank you for reviewing my PR @a-robson

@a-robson
Copy link

You're welcome. I've looked over your changes and they are all really good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complete Volunteer to add when work is complete and review comments have been addressed 📅 Sprint 1 Assigned during Sprint 1 of this module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants