-
-
Notifications
You must be signed in to change notification settings - Fork 278
London | 26-ITP-JAN | Abdul Moiz | Sprint 1 | Data Groups #947
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
Open
A-Moiz
wants to merge
7
commits into
CodeYourFuture:main
Choose a base branch
from
A-Moiz:sprint-one
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c2c49eb
Completed exercise in fix directory
A-Moiz 04c5cc3
Completed exercises in implement directory
A-Moiz 63f79bb
Completed exercise in refactor directory
A-Moiz 95d7bdd
Added check for Nan, Infinity and -Infinity in median.js
A-Moiz a2029d9
Utilised toBeCloseTo for floating point values sum
A-Moiz e7602ab
Added test to check if return value is a copy of the original array i…
A-Moiz a3144be
Updated test description in sum.test.js
A-Moiz 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,23 @@ | ||
| function dedupe() {} | ||
| function dedupe(input) { | ||
| // Check if the input is an array | ||
| if (!Array.isArray(input)) { | ||
| return null; | ||
| } | ||
| // Check for empty array | ||
| if (input.length === 0) { | ||
| return []; | ||
| } | ||
| // New array to hold deduped values | ||
| const newArray = []; | ||
| // Go through each element in the input array | ||
| for (let i = 0; i < input.length; i++) { | ||
| const element = input[i]; | ||
| // If the element is not already in newArray, add it | ||
| if (!newArray.includes(element)) { | ||
| newArray.push(element); | ||
| } | ||
| } | ||
| return newArray; | ||
| } | ||
|
|
||
| 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) { | ||
| // Check if input is an array | ||
| if (!Array.isArray(elements)) { | ||
| return null; | ||
| } | ||
| // Filter only numeric values | ||
| const numericElements = elements.filter((item) => typeof item === "number"); | ||
| // Check if array is empty after filtering | ||
| if (numericElements.length === 0) { | ||
| return -Infinity; | ||
| } | ||
| // Return the maximum value | ||
| return Math.max(...numericElements); | ||
| } | ||
|
|
||
| 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,23 @@ | ||
| function sum(elements) { | ||
| // Check if input is an array | ||
| if (!Array.isArray(elements)) { | ||
| return null; | ||
| } | ||
| // Check if array is empty | ||
| if (elements.length === 0) { | ||
| return 0; | ||
| } | ||
| // Filter only numeric values | ||
| const numericElements = elements.filter((item) => typeof item === "number"); | ||
| if (numericElements.length === 0) { | ||
| return -Infinity; | ||
| } | ||
| // Calculate the sum of numeric values | ||
| let total = 0; | ||
| for (let i = 0; i < numericElements.length; i++) { | ||
| total += numericElements[i]; | ||
| } | ||
| return total; | ||
| } | ||
|
|
||
| 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
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.