Birmingham | 26-ITP-May | Ogbemi Mene | Sprint 1 | Module data group/sprint 1a - #1285
Birmingham | 26-ITP-May | Ogbemi Mene | Sprint 1 | Module data group/sprint 1a#1285meneogbemi42-bit wants to merge 12 commits into
Conversation
LonMcGregor
left a comment
There was a problem hiding this comment.
Still some things to work on carried over from previous PR
| } | ||
|
|
||
| const salaries = [10, 40, 50, 70, 90]; | ||
| const median = calculateMedian(salaries); |
There was a problem hiding this comment.
You still need to move these tests away from the implementation into the testing file.
| if (numbersOnly.length === 0) { | ||
| return -Infinity; | ||
| } | ||
| return Math.max(...numbersOnly); |
There was a problem hiding this comment.
See my original comment from the other PR - is it possible to implement this without using the build in max function?
There was a problem hiding this comment.
yes it is possible, i was just using a short cut method, but i have used the loop function instead of the build in max function
| (item) => typeof item === "number" && !isNaN(item) | ||
| ); | ||
|
|
||
| if (numbersOnly.length === 0) { |
There was a problem hiding this comment.
Can you answer my comment from the original PR - When is this if condition needed?
There was a problem hiding this comment.
after commenting the if function out i saw it was not really need. the test till passed without it. i added it because i thought it will deal with with returuning the empty arrey value.
Self checklist
this PR core implementation shows how to Fixe and implement array utility functions with robust error handling:
median – Filters numbers, sorts, and returns middle value (or average for even-length arrays)
dedupe – Removes duplicates using Set
max – Finds maximum numeric value
sum – Totals numeric values
All handle edge cases (empty arrays, mixed types, null/undefined) and include comprehensive test coverage.