Repository navigation
London | 26-ITP-Sep | Mars Adesina | Sprint 1 | Data groups #1494
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
marscancode
wants to merge
59
commits into
CodeYourFuture:main
Choose a base branch
from
marscancode:coursework/data-groups-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.
Open
Changes from all commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
2071acd
fixed median calculation for odd and even arrays
marscancode 19742a7
Sorted a copy before calculating the median
marscancode aca8e91
Added a check in function to make sure the input is an array
marscancode 091e875
Added a a check in function for empty arrays
marscancode c4d3648
added check in function that the array only contains numbers
marscancode fc92cc2
removed duplicate values from arrays
marscancode a078653
added describe median function
marscancode e02094b
Added tests for describeMedian
marscancode 1875b30
Ignore prep directory
marscancode f9a47c7
Implemented findMax function
marscancode 1516690
added empty and single-number tests for findMax
marscancode 445b260
Added test for both positive and negative numbers
marscancode 4337038
Add test for array with negative numbers
marscancode 6fd0acf
added test for decimal numbers
marscancode 8490f09
added test for value that isnt a number
marscancode 7b42dd0
Completed findMax tests
marscancode 9f17e6d
added first test for calculateMean, it fails
marscancode 19d9c71
implemented function calculateMean
marscancode 063182a
test to check wether calculateMean works given an array with a single…
marscancode 1b1468e
test to check how calculateMean handles an array of negative numbers,…
marscancode d90b2cf
test to check wether calculateMean handles an array of decimal number…
marscancode 7547c25
added test to check wether calculateMean throws an error when given a…
marscancode c87f412
implemented calculateMean to handle empty arrays
marscancode f24628a
test to check if calculateMean throws an error when given a string in…
marscancode c574535
implemented calculateMean to handle a string, tests pass
marscancode c427aa2
added tests for calculateMean for invalid non-array values
marscancode 108c621
deleted duplicate empty array test
marscancode 03ec939
added test to check if calculateMedian throws an error when given an …
marscancode 3048952
implemented calculate mean to only take in arrays with number values
marscancode e6bec3a
added test for empty sum array
marscancode 15f68c9
implemented the sum function using reduce, test passes
marscancode e4a79ce
added test to check if an array with one number returns the number
marscancode 51a5109
added test to check if sum can handle negative numbers
marscancode 597c5f5
added test for sum with decimal numbers
marscancode 28a59d0
added test to check if sum throws an error when given an array contai…
marscancode 4e83c4c
implemented sum function using reduce
marscancode c9f7754
implemented sum function to throw an error if given an array containi…
marscancode 75d26ab
added test for non-array input in sum function
marscancode 9abe6cc
implemented sum function to check array input if incorrect throw error
marscancode 80d4434
Add tests for non-array and missing sum arguments
marscancode 9ea7f04
added test for number input in sum function
marscancode 556c1a7
refactored includes to use a for...of loop, tests pass
marscancode 6208f35
refactored calculateMedian to use toSorted()
marscancode c2833b9
refactored dedupe to remove unnecessary comments
marscancode c41165f
added empty array test for dedupe
marscancode 7dd48ff
test to check dedupe returns a copy when no duplicates
marscancode 4cbe9de
added dedupe tests for arrays with and without duplicates
marscancode e62eb3d
refactored describeMedian to removed uneeded comments
marscancode bf4297e
added NaN test for findMax
marscancode 374884b
implemented findMax to reject NaN values
marscancode f14ba36
fixed indentation using prettier
marscancode 5389d85
add test to check calculateMean rejects NaN
marscancode eab3a2d
implemented calculateMean to reject NaN values
marscancode d5dd56f
refactored calculateMean variable names
marscancode 9597250
added test to check if sum rejects NaN, it fails
marscancode f53b205
implemented sum to reject NaN values
marscancode 280d6e8
updated test to use toBeCloseTo for decimal mean
marscancode eb87dd2
tests to cover infinity values in calculateMean, tests pass
marscancode 5670709
added test to cover infinity values in sum
marscancode 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ node_modules | |
| **/.DS_Store | ||
| .idea | ||
| package-lock.json | ||
| /prep/ | ||
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,15 @@ | ||
| function dedupe() {} | ||
| function dedupe(numbers) { | ||
| const uniqueNumbers = []; | ||
|
|
||
| for (let i = 0; i < numbers.length; i++) { | ||
| const currentValue = numbers[i]; | ||
|
|
||
| if (!uniqueNumbers.includes(currentValue)) { | ||
| uniqueNumbers.push(currentValue); | ||
| } | ||
| } | ||
|
|
||
| return uniqueNumbers; | ||
| } //function ends | ||
|
|
||
| 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,22 @@ | ||
| function findMax(elements) { | ||
| if ( | ||
| !Array.isArray(elements) || | ||
| !elements.every( | ||
| (element) => typeof element === "number" && !Number.isNaN(element) | ||
| ) | ||
| ) { | ||
| throw new Error("findMax requires an array of numbers"); | ||
| } | ||
|
|
||
| let max = -Infinity; | ||
|
|
||
| for (let i = 0; i < elements.length; i++) { | ||
| if (elements[i] > max) { | ||
| max = elements[i]; | ||
| } | ||
| } | ||
|
|
||
| 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,3 +1,20 @@ | ||
| function calculateMean(list) {} | ||
| function calculateMean(list) { | ||
| if (!Array.isArray(list)) { | ||
| throw new Error("calculateMean requires an array of numbers"); | ||
| } | ||
| if (list.length === 0) { | ||
| throw new Error("calculateMean requires a non-empty array"); | ||
| } | ||
| if ( | ||
| !list.every((number) => typeof number === "number" && !Number.isNaN(number)) | ||
| ) { | ||
| throw new Error("calculateMean requires an array of numbers"); | ||
| } | ||
| const total = list.reduce((runningTotal, number) => { | ||
| return runningTotal + number; | ||
| }, 0); | ||
|
|
||
| return total / list.length; | ||
| } | ||
|
|
||
| module.exports = calculateMean; |
|
marscancode marked this conversation as resolved.
Resolved
|
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,17 @@ | ||
| function sum(elements) { | ||
| if (!Array.isArray(elements)) { | ||
| throw new Error("sum requires an array of numbers"); | ||
| } | ||
| if ( | ||
| !elements.every( | ||
| (element) => typeof element === "number" && !Number.isNaN(element) | ||
| ) | ||
| ) { | ||
| throw new Error("sum requires an array of numbers"); | ||
| } | ||
| const sum = elements.reduce((sum, number) => { | ||
| return number + sum; | ||
| }, 0); | ||
|
marscancode marked this conversation as resolved.
Resolved
|
||
| return sum; | ||
| } | ||
|
|
||
| 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
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.
Uh oh!
There was an error while loading. Please reload this page.