-
-
Notifications
You must be signed in to change notification settings - Fork 283
Birmingham | ITP Jan 2026 | Arunkumar Akilan | Sprint 1 | Data Groups #992
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
arunkumarakilan
wants to merge
6
commits into
CodeYourFuture:main
from
arunkumarakilan:coursework/Sprint1
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5c5e165
fix: handle non-array and non-numeric inputs in calculateMedian
arunkumarakilan 4700cb1
Implement dedupe function
arunkumarakilan 2b3cdc0
Implement findMax function and ignore non-numeric values
arunkumarakilan f59026c
Implement sum function
arunkumarakilan b473ef0
Refactor includes to use for...of loop
arunkumarakilan f2f5f60
fix dedupe indentation and confirm empty array validation
arunkumarakilan 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,17 @@ | ||
| function dedupe() {} | ||
| function dedupe(list) { | ||
| if (list.length=== 0) | ||
| { | ||
| return []; | ||
| } | ||
| let result = []; | ||
| for (let item of list) | ||
| { | ||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,18 @@ E.g. dedupe([1, 2, 1]) target output: [1, 2] | |
| // When passed to the dedupe function | ||
| // Then it should return an empty array | ||
| test.todo("given an empty array, it returns an empty array"); | ||
|
|
||
| test("given an empty array, it returns an empty array", ()=>{ | ||
| const list = []; | ||
| expect(dedupe(list)).toEqual([]); | ||
| }); | ||
| test | ||
| ("array with no duplicate should return copy of original", ()=>{ | ||
| let list = [1,2,4,6,9,8]; | ||
| expect(dedupe(list)).toEqual([1,2,4,6,9,8]); | ||
|
Comment on lines
+25
to
+27
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. "copy" is an interesting word here - are you testing that it returns a copy? If your function just did |
||
| }); | ||
| test("shoiuld remove the duplicate value and preserving the first occurebce",()=>{ | ||
| expect(dedupe([5, 1, 1, 2, 3, 2, 5, 8])).toEqual([5,1,2,3,8]); | ||
| }) | ||
| // Given an array with no duplicates | ||
| // When passed to the dedupe function | ||
| // Then it should return a copy of the original array | ||
|
|
||
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,19 @@ | ||
| function findMax(elements) { | ||
| if(elements.length === 0) | ||
| { | ||
| return -Infinity; | ||
| } | ||
| let max = -Infinity ; | ||
| for (const item of elements) | ||
| { | ||
| if (typeof item === 'number') | ||
| { | ||
| max = Math.max(max , item); | ||
| } | ||
|
|
||
|
|
||
| } | ||
| return max; | ||
| } | ||
|
|
||
| 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,19 @@ | ||
| function sum(elements) { | ||
| if (elements.length === 0) | ||
| { | ||
| return 0; | ||
| } | ||
| let total = 0 ; | ||
| for (const item of elements) | ||
| { | ||
| if (typeof item === 'number') | ||
| { | ||
| total = total + item; | ||
| } | ||
|
|
||
|
|
||
| } | ||
| 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.
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.
Do you need this special case? If you removed the
if (list.length === 0)check here, what would break?