-
-
Notifications
You must be signed in to change notification settings - Fork 283
Sheffield | 26-Jan-ITP | Daniel Aderibigbe | Sprint 1 | Coursework/sprint 1 #986
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e628a41
fix exercise completed
Dan2Clouted e2f4c99
dedupe exercise completed.
Dan2Clouted d128741
max exercise completed
Dan2Clouted 45812d4
sumtest exercise completed.
Dan2Clouted e0ff101
refactor and stretch exercise completed.
Dan2Clouted c96038b
updated the task based on reviewes feedback
Dan2Clouted cc033e1
Merge branch 'main' into coursework/sprint-1
Dan2Clouted 68bc3bb
fix the bug
Dan2Clouted b98c6f1
Fix the bugs
Dan2Clouted 527666a
hopefully fixed this time
Dan2Clouted File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,12 @@ | ||
| function dedupe() {} | ||
| function dedupe(array) { | ||
| const result = []; | ||
|
|
||
| for (const item of array) { | ||
| if (!result.includes(item)) { | ||
| result.push(item); | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| module.exports = dedupe; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,16 @@ | ||
| function findMax(elements) { | ||
| let max = -Infinity; | ||
|
|
||
| for (let i = 0; i < elements.length; i++) { | ||
| if ( | ||
| typeof elements[i] === "number" && | ||
| !Number.isNaN(elements[i]) && | ||
| elements[i] > max | ||
| ) { | ||
| max = elements[i]; | ||
| } | ||
| } | ||
| return max; | ||
| } | ||
|
Dan2Clouted marked this conversation as resolved.
|
||
|
|
||
| module.exports = findMax; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,12 @@ | ||
| function sum(elements) { | ||
| let total = 0; | ||
|
|
||
| for (let i = 0; i < elements.length; i++) { | ||
| if (Number.isFinite(elements[i])) { | ||
| total += elements[i]; | ||
| } | ||
| } | ||
| return total; | ||
| } | ||
|
Dan2Clouted marked this conversation as resolved.
|
||
|
|
||
| module.exports = sum; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
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. I think this exercise also involves "reading data from files". If you are up to the challenge, can you write a script that can read the numbers from a file and then output their sums? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| function sum(list) { | ||
| return list.reduce((a, b) => a + b, 0); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.