Skip to content

Conversation

@AhmadHmedann
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

I have implemented the sum, max, dedupe, and median functions, and written comprehensive tests for each. I also refactored the includes function.

Questions

const numericList = list.filter(
(item) => typeof item === "number" && !isNaN(item)
);
I know how to use it and why, but I don’t know how it works. When it says it must be an array, does that mean the structure should be an array like const x = [...]? and const x = 23 is not an array, right?

…n array,otherwise return null..........Filtered out non-numeric element .......Added a check for emty numeric arrays ....Cloned the array to prevent mutation(avoid side effects)......Sorted numbers in ascending order.......Calculated the median for both even and odd length
…e array is empty and update the function's code to handles this scenario
…andle all test scenarios the scenarios are \n-empty array\n -Single elemnt array \n -Mixed positive and negative numbers\n-All negative numbers\n-Decimal values\n-Array with mixed (numeric/non-numeric)values \n- Array with only non-numeric values
…all test scenarios the scenarios are \n-empty array\n -Single elemnt array \n -Mixed positive and negative numbers\n-All negative numbers\n-Decimal values\n-Array with mixed (numeric/non-numeric)values \n- Array with only non-numeric value
@AhmadHmedann AhmadHmedann added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 12, 2025
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.

Can you check if any of this general feedback can help you further improve your code?
https://github.com/CodeYourFuture/Module-Data-Groups/blob/sprint-1-feedback/Sprint-1/feedback.md

Doing so can help reviewers speed up the review process. Thanks.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 20, 2025
@AhmadHmedann AhmadHmedann added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Dec 1, 2025
return (numericList[middleIndex] + numericList[middleIndex - 1]) / 2;
} else {
const middleIndex = Math.floor(numericList.length / 2);
const median = numericList.splice(middleIndex, 1)[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a much more efficient syntax to access an element at a particular index without deleting any element from the array.

Comment on lines 5 to 13
for (let i = 1; i < elementsClone.length; i++) {
for (let j = i; j > 0; j--) {
if (elementsClone[i] === elementsClone[j - 1]) {
elementsClone.splice(i, 1);
i--; // because I deleted one element from my array
break;
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You approach works. Here are some suggestions for you to consider:

  • Deleting an element from an array is a relatively costly operation. A more efficient alternative is to append an element to a new array only if the element does not exist in the array.

  • Most modern programming languages offer a built-in class that implements the Set data structure. It is optimized to keeps only unique items. Do look up how to use the Set class in JS.

@cjyuan
Copy link
Contributor

cjyuan commented Dec 2, 2025

const numericList = list.filter(
(item) => typeof item === "number" && !isNaN(item)
);
I know how to use it and why, but I don’t know how it works. When it says it must be an array, does that mean the structure should be an array like const x = [...]? and const x = 23 is not an array, right?

I am not sure what your "it" in "... it must be an array" refers to.

For that code to work, list must be an array (i.e., an instance of Array or TypedArray).

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Dec 2, 2025
@AhmadHmedann AhmadHmedann added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Dec 5, 2025
@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Dec 5, 2025
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 all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants