generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 220
Glasgow | 25-ITP-SEP | Fares Bakhet | Sprint 1 | Coursework/sprint 1 #825
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
Fares-Bakhet
wants to merge
14
commits into
CodeYourFuture:main
from
Fares-Bakhet:coursework/sprint-1
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
dcdec45
Fix the implementation
Fares-Bakhet 589c8d9
Implement a Deduplicate function
Fares-Bakhet 3ebe1f9
Run tests for the Deduplicate function
Fares-Bakhet 8817635
Implement findMax function
Fares-Bakhet 744af5d
Adding tests for max.js file
Fares-Bakhet 61a84ce
Implementing a sum function
Fares-Bakhet 1762ae0
Run tests for the sum.js file
Fares-Bakhet bf825f1
Editing the code
Fares-Bakhet c8d3734
Refactoring the implementation
Fares-Bakhet cd9b36a
fix deupe.test.js file
9420f6a
fix file
c8f6f8f
fix max.js file
89e0e23
Editing max.js file
8495512
Editing sum.test.js file
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
Some comments aren't visible on the classic Files Changed page.
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,6 @@ | ||
| function dedupe() {} | ||
| function dedupe(arr) { | ||
| const deduplicates = arr.filter((item, index) => arr.indexOf(item) === index); | ||
| return deduplicates; | ||
| } | ||
|
|
||
| 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,13 @@ | ||
| function findMax(elements) { | ||
| function findMax(arr) { | ||
| if (!Array.isArray(arr) || arr.length === 0) return -Infinity; | ||
|
|
||
| const numbers = arr.filter((n) => typeof n === "number" && !isNaN(n)); | ||
|
|
||
| if (numbers.length > 0) { | ||
| return Math.max(...numbers); | ||
| } | ||
|
|
||
| return arr[arr.length - 1]; | ||
| } | ||
|
|
||
| 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,11 @@ | ||
| function sum(elements) { | ||
| let totalSum = 0; | ||
| for (let i = 0; i < elements.length; i++) { | ||
| if (typeof elements[i] === "number") { | ||
| totalSum += elements[i]; | ||
| } | ||
| } | ||
| return totalSum; | ||
| } | ||
|
|
||
| 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
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.
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 an odd choice of value to return.
Is there any value you don't expect
findMax()to ever return?