Repository navigation
Manchester | 26-ITP-Sep | Rahana Suleiman| Sprint 1 | Data Groups Coursework #1493
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
rahanasuleiman8-ship-it
wants to merge
24
commits into
CodeYourFuture:main
Choose a base branch
from
rahanasuleiman8-ship-it:sprint-1
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.
+325
−63
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
bd388e4
Implement input validation and error handling in calculateMedian func…
rahanasuleiman8-ship-it dbf4e21
Add a blank line for better readability in dedupe test file
rahanasuleiman8-ship-it 1e13f78
Add tests for dedupe function to validate behavior with empty and uni…
rahanasuleiman8-ship-it d940b04
Implement dedupe function to remove duplicate values from an array
rahanasuleiman8-ship-it 26c125e
Implement describeMedian function to calculate and return the median …
rahanasuleiman8-ship-it 96de195
Add tests for describeMedian function to validate median calculation …
rahanasuleiman8-ship-it 9ec2074
Add test case for describeMedian to handle empty array input
rahanasuleiman8-ship-it 547e68b
Add test case for describeMedian to handle non-array input
rahanasuleiman8-ship-it fe34b63
Refactor describeMedian tests to remove todos and ensure correct erro…
rahanasuleiman8-ship-it 411ad3f
Refactor describeMedian tests to improve clarity and organization
rahanasuleiman8-ship-it 1c76aa4
Improve error handling in describeMedian by capturing error parameter
rahanasuleiman8-ship-it 34fbfe5
Implement findMax function with input validation and error handling
rahanasuleiman8-ship-it 866d1d0
Add tests for findMax function to cover various scenarios including e…
rahanasuleiman8-ship-it bc3b0d2
Implement calculateMean function with input validation and error hand…
rahanasuleiman8-ship-it ddaa794
Add test for calculateMean function to validate mean calculation for …
rahanasuleiman8-ship-it 3e45546
Add test for calculateMean function to verify single number input
rahanasuleiman8-ship-it b1069fe
Add test for calculateMean function to validate mean calculation for …
rahanasuleiman8-ship-it 4faa807
Add tests for calculateMean function to verify error handling for emp…
rahanasuleiman8-ship-it 35df2b2
Add test for calculateMean function to verify error handling for no a…
rahanasuleiman8-ship-it 9d10901
Add tests for calculateMean function to validate error handling for n…
rahanasuleiman8-ship-it 292c6ed
Update test for calculateMean function to use different input values …
rahanasuleiman8-ship-it 59d9646
Add sum function to calculate the total of an array, including input …
rahanasuleiman8-ship-it 55d7528
Add tests for sum function to validate various input scenarios and er…
rahanasuleiman8-ship-it 02e7fdc
Refactor includes function to use for...of loop for improved readability
rahanasuleiman8-ship-it 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,4 @@ | ||
| function dedupe() {} | ||
| function dedupe(arr) { | ||
| return [... new Set(arr)] | ||
| } | ||
| 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
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 findMax(elements) { | ||
| // 1. Check if input is a valid array and not null/undefined | ||
| if (!Array.isArray(elements)) { | ||
| throw new Error("findMax requires an array of numbers"); | ||
| } | ||
|
|
||
| // 2. Handle empty array edge case per requirements | ||
| if (elements.length === 0) { | ||
| return -Infinity; | ||
| } | ||
|
|
||
| // 3. Validate that every item in the array is strictly a number (no strings, null, etc.) | ||
| for (const item of elements) { | ||
| if (typeof item !== "number" || Number.isNaN(item)) { | ||
| throw new Error("findMax requires an array of numbers"); | ||
| } | ||
| } | ||
|
|
||
| // 4. Return the maximum number using Math.max | ||
| return Math.max(...elements); | ||
| } | ||
|
|
||
| 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,3 +1,25 @@ | ||
| function calculateMean(list) {} | ||
| function calculateMean(list) { | ||
| // 1. Check if input is a valid array | ||
| if (!Array.isArray(list)) { | ||
| throw new Error("calculateMean requires an array of numbers"); | ||
| } | ||
|
|
||
| module.exports = calculateMean; | ||
| // 2. Check if the array is empty | ||
| if (list.length === 0) { | ||
| throw new Error("calculateMean requires a non-empty array"); | ||
| } | ||
|
|
||
| // 3. Validate that every item in the array is strictly a number | ||
| let sum = 0; | ||
| for (const item of list) { | ||
| if (typeof item !== "number" || Number.isNaN(item)) { | ||
| throw new Error("calculateMean requires an array of numbers"); | ||
| } | ||
| sum += item; | ||
| } | ||
|
|
||
| // 4. Return the calculated mean | ||
| return sum / list.length; | ||
| } | ||
|
|
||
| module.exports = calculateMean; |
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,25 @@ | ||
| function sum(elements) { | ||
| // 1. Check if input is a valid array | ||
| if (!Array.isArray(elements)) { | ||
| throw new Error("sum requires an array of numbers"); | ||
| } | ||
|
|
||
| // 2. Handle empty array edge case (sum of empty array is 0) | ||
| if (elements.length === 0) { | ||
| return 0; | ||
| } | ||
|
|
||
| // 3. Validate that every item in the array is strictly a number | ||
| let total = 0; | ||
| for (const item of elements) { | ||
| if (typeof item !== "number" || Number.isNaN(item)) { | ||
| throw new Error("sum requires an array of numbers"); | ||
| } | ||
| total += item; | ||
| } | ||
|
|
||
| // 4. Return the calculated sum | ||
| return total; | ||
| } | ||
|
|
||
| module.exports = sum; | ||
| module.exports = sum; | ||
Oops, something went wrong.
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.
This edge case is actually not needed, because in your algorithm below:
0into totalforloop will not run due to no item in theelements0(which is the same as line 9).