-
-
Notifications
You must be signed in to change notification settings - Fork 202
West Midlands | ITP-Sep-25 | Ahmad Ehsas | sprint 1 | Data groups #804
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?
Changes from all commits
96e54cd
d577680
3ecbe9f
0467d03
a9a5914
f666df4
b51939c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with your logical flow here. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,15 @@ | ||
| function dedupe() {} | ||
| function dedupe(array) { | ||
| if (!Array.isArray(array)) { | ||
| return []; | ||
| } | ||
|
|
||
| const result = []; | ||
| for (let item of array) { | ||
| if (!result.includes(item)) { | ||
| result.push(item); | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| module.exports = dedupe; |
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also works, good work! |
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is another good attempt, but It should be -Infinity and not Infinity, good work! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,17 @@ | ||
| function findMax(elements) { | ||
| const numericElements = elements.filter( | ||
| (elements) => typeof elements === "number" | ||
| ); // filter out only numeric values | ||
|
|
||
| // If there are no numeric values, return infinity | ||
| if (numericElements.length === 0) { | ||
| return -Infinity; | ||
| } | ||
|
|
||
| // use Math.max with spread (...) to get the maximum number | ||
| return Math.max(...numericElements); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| module.exports = findMax; |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I ran these tests they didn't pass - can you check them. |
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works too good one! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,9 @@ | ||
| function sum(elements) { | ||
| // Filter for numbers only | ||
| const numericValues = elements.filter((item) => typeof item === "number"); | ||
|
|
||
| // Add the numbers | ||
| return numericValues.reduce((total, num) => total + num, 0); | ||
| } | ||
|
|
||
| module.exports = sum; |
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.
This is a really good attempt at the median function, good work!