-
-
Notifications
You must be signed in to change notification settings - Fork 153
London | May-2025 | Halyna Kozlovska | Module Data Groups | Sprint 1 #542
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
- fix and improve median calculation logic
- refactor findMax function; - add comprehensive tests covering all cases
- refactor max.test.js to use a single describe block
- refactor sum function; - add comprehensive tests for all cases: empty arrays, single numbers, negative numbers, decimals, mixed types, and arrays with only non-numeric values.
- implement dedupe function; - add tests to verify the function's behavior for various cases: empty arrays, arrays with no duplicates, array with string or number duplicates
- refactor includes function to use for...of loop; - update tests assertions to use toBe instead of toEqual; - fixed the empty array test to include a target argument
@@ -1 +1,10 @@ | |||
function dedupe() {} | |||
function dedupe(array) { | |||
let result = []; |
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.
For very large arrays, a Set can provide better performance than using an Array. Consider updating this implementation to use a set. See here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
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.
@AdnanGondal Thanks for your comment — good point! Using a Set makes lookups faster (O(1) vs O(n)) and keeps values unique, which is great for large arrays. Here the time and space difference is small because the dataset is tiny, but I’ll keep Set in mind for future cases where performance matters more.
sum += element; | ||
} | ||
} | ||
return Math.round(sum * 100) / 100;; |
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 tell me what this line does?
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.
@AdnanGondal Line 9 rounds the total sum to two decimal places before returning it.
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.
Great attempt - have just added a comment and question, please address those and I will Complete
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.
Looks good to me
Learners, PR Template
Self checklist
Changelist
Questions
Ask any questions you have for your reviewer.