Repository navigation
London |26-ITP-Sep| Maharit Belai| Sprint 1 | coursework sprint-1 #1483
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
MaharitB
wants to merge
52
commits into
CodeYourFuture:main
Choose a base branch
from
MaharitB:coursework/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
52 commits
Select commit
Hold shift + click to select a range
26b44e9
added a code to fix a test fail,two test passed for even number input…
MaharitB 671b6c4
added a code for a test that failed when unsorted array, 4 tests passed
MaharitB 0eedf37
added a code that throws a test when passed empty array,test passed
MaharitB df36aae
added a code that checks if the array has number or other values , fo…
MaharitB b9818eb
added codes for the test failling on array of string,mixing numbers, …
MaharitB bd50d80
edited codes ,where thier position can catch the error early(the one …
MaharitB 0a0c4d5
edited a code for sorting the array and saving it with out changing …
MaharitB 3fdbba5
added a test for an array with no duplicate.
MaharitB 1ac1a8c
added a return. test passed
MaharitB a8c8e5b
wrote test for number and strings and test failed
MaharitB 8b2277a
wrote a code to make the test passed .test passed
MaharitB 7a8e98b
added a test for test.todo. test passed
MaharitB 20f698c
wrote a test to replace the test todo test passed
MaharitB 720fdaf
wrote a code that calles the function calculate median .test passed
MaharitB 30cf7cd
edited some tests and added some more test,test failed
MaharitB f8736d9
added try and catch block to return the error message. test passed
MaharitB ab03db5
implemented a function that finds the largest numerical element of an…
MaharitB 3d22657
added a test that should return -Infinity when given empty array.test…
MaharitB fd5644f
added Math.max to the code so it can return -Infinity,test passed
MaharitB f15e553
addeda a test that reurn the nember when passed one number
MaharitB f5e48dc
added to tests that would return the largest number when given -ve an…
MaharitB cd439b7
added a test for largest decimal numbers and test passed
MaharitB f2e4871
added test that throws an error when given a value that is not number…
MaharitB ea1f770
added atest that throws an error when given non number value in an array
MaharitB 2d230bf
deleted the commented code and added the for loop to check on the val…
MaharitB 1f598f1
wrote test to return an error when given non array arguments,two test…
MaharitB 73325f6
added a code that throws an error when non array aruments passed
MaharitB 8ef5244
implemented a function calculateMean
MaharitB aae9679
added a test for the test .todo test passed
MaharitB 90f3ec4
added two test for asingle number and for -ve and +ve number in an ar…
MaharitB 7edbeee
added a test that returns an error when given empty array
MaharitB 3576733
added a code that throws an error when empty array is given
MaharitB e460491
added a test for a given value that is non array.test failed
MaharitB 251329c
added the code to check if the argument is array or not, test passed
MaharitB 8101cc2
addeda test for no argument passed to the functon, test passed
MaharitB 3207a97
added a test for a n array containing non number value ,test failed
MaharitB 1da066e
added a code that throws error when an array containing a non number …
MaharitB be6ec8d
added a test for an argument that is not array
MaharitB 9ba29de
implement the function sum
MaharitB 1cac38e
wrote a test for an empty array that should return zero.test passed
MaharitB 43647bb
wrote a test for an array with one number to return one number,test p…
MaharitB 49baa11
wrote a test for an array with negative numbers, test passed
MaharitB dab9188
added a code that throws an error when a non number value is in the a…
MaharitB 12e8cb0
added a test for adding decimal and throwing and error if non number …
MaharitB c4a0488
added tests that throw error when the argument is non array
MaharitB 7165d34
added a code that would throw error when element is not array
MaharitB 31a874c
refractored the code . the test still passes
MaharitB 57a5cc3
changed itemArray ti item as advised
MaharitB ee47d72
added two taste cases for unordered number and character,both test pa…
MaharitB b560e2c
changed itemArray to item as advised
MaharitB 58d46b5
added two test cases for unordered number and character,both test passed
MaharitB 02f2d48
Merge branch 'coursework/sprint-1' of github.com:MaharitB/Module-Data…
MaharitB 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,12 @@ | ||
| function dedupe() {} | ||
| function dedupe(array) { | ||
| const withOutDup = []; | ||
| for (let i = 0; i < array.length; i++) { | ||
| const item = array[i]; | ||
| if (!withOutDup.includes(item)) { | ||
| withOutDup.push(item); | ||
| } | ||
| } | ||
|
|
||
| return withOutDup; | ||
| } | ||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,12 +21,33 @@ const describeMedian = require("./describe-median.js"); | |
| // When passed to describeMedian | ||
| // Then it should return "The median is " followed by the median | ||
| // Delete this test.todo and replace it with a test. | ||
| test.todo('given [1, 2, 3], returns "The median is 2"'); | ||
| test("returns the correct median when given [1,2,3]", () => { | ||
| expect(describeMedian([1, 2, 3])).toEqual(2); | ||
| }); | ||
|
|
||
| // Given an empty array | ||
| // When passed to describeMedian | ||
| // Then it should return "Could not calculate a median: calculateMedian requires a non-empty array" | ||
|
|
||
| test("returns an error message when given an empty array", () => { | ||
| expect(describeMedian([])).toEqual( | ||
| "Could not calculate a median:calculateMedian requires a non-empty array" | ||
| ); | ||
| }); | ||
| // Given something that isn't an array of numbers, e.g. "banana" | ||
| // When passed to describeMedian | ||
| // Then it should return "Could not calculate a median: calculateMedian requires an array of numbers" | ||
| test("returns an error message when given a string of array", () => { | ||
| expect(describeMedian(["banana"])).toEqual( | ||
| "Could not calculate a median:calculateMedian requires an array of numbers" | ||
| ); | ||
| }); | ||
| test("return an error message when given a number", () => { | ||
| expect(describeMedian(123)).toEqual( | ||
| "Could not calculate a median:calculateMedian requires an array of numbers" | ||
| ); | ||
| }); | ||
| test("return an error message when given list of strings of array", () => { | ||
| expect(describeMedian(["one", "two", "three"])).toEqual( | ||
| "Could not calculate a median:calculateMedian requires an array of numbers" | ||
| ); | ||
| }); | ||
|
Comment on lines
+39
to
+53
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. Well done. Good test cases coverage. |
||
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) { | ||
| if (!Array.isArray(elements)) { | ||
| throw new Error("findMax requires an array of numbers"); | ||
| } | ||
| for (let num of elements) { | ||
| if (typeof num !== "number") { | ||
| throw new Error("findMax requires an array of numbers"); | ||
| } | ||
| } | ||
| 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,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"); | ||
| } | ||
| for (const item of list) { | ||
| if (typeof item !== "number") { | ||
| throw new Error("calculateMean requires an array of numbers"); | ||
| } | ||
| } | ||
| let total = 0; | ||
| for (const num of list) { | ||
| total += num; | ||
| } | ||
| return (mean = total / 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,17 @@ | ||
| function sum(elements) { | ||
| if (!Array.isArray(elements)) { | ||
| throw new Error("sum requires an array of numbers"); | ||
| } | ||
| for (const num of elements) { | ||
| if (typeof num !== "number") { | ||
| throw new Error("sum requires an array of numbers"); | ||
| } | ||
| } | ||
| let total = 0; | ||
| for (const num of elements) { | ||
| total += num; | ||
| } | ||
| return total; | ||
| } | ||
|
|
||
| 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.
All these test cases are testing consecutive duplications. How about
dedupe([5, 1, 1, 2, 3, 2, 5, 8])? Does it return[5, 1, 2, 3, 8]or[1, 3, 2, 5, 8]? Please add at least one non-consecutive duplication case. Thank you.