Repository navigation
Birmingham | 26-ITP-May | Toluwalase Tiamiyu | Sprint 1 | Exercises #1295
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 9 commits
f7ce2f5
25d86f0
5201774
4e5a380
1c07c61
c52700a
0667c52
7d6ad3c
2abe1ec
21c4d2a
4b9ea66
87afb14
b70a0a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| function dedupe() {} | ||
| function dedupe(list) { | ||
| return list.filter((item, index) => index === list.indexOf(item)); | ||
| } | ||
|
|
||
| module.exports = dedupe; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| function findMax(elements) { | ||
| const numbers = elements.filter((item) => typeof item === "number"); | ||
| return Math.max(...numbers); | ||
| } | ||
|
|
||
| module.exports = findMax; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| function sum(elements) { | ||
| const numbers = elements.filter((item) => typeof item === "number"); | ||
|
Contributor
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. What do you expect from the following function calls (on extreme cases)?
Author
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. No, it wouldn’t return what is expect, i have Incorporated these extreme cases in the test and also improved the sum.js code to cater for such extremes. |
||
| return numbers.reduce((total, current) => total + current, 0); | ||
| } | ||
|
|
||
| module.exports = sum; | ||
Uh oh!
There was an error while loading. Please reload this page.