Repository navigation
Conversation
…containing null,and undefined. test passed
…that checs if list is array or not). test passed
…he original array, test passed
…d +ve number and only -ve number
…ue of the array if they are numbers or not,test passed
…ray, one test failed
hackertainment
left a comment
There was a problem hiding this comment.
Just need to fix dedupe.test.js and the other comments are for your future reference only. You are almost there and please keep it up. Thank you.
| function dedupe(array) { | ||
| const withOutDup = []; | ||
| for (let i = 0; i < array.length; i++) { | ||
| const itemArray = array[i]; |
There was a problem hiding this comment.
The variable name itemArray may be a bit confusing. Maybe consider arrayItem or even better just item in the future.
| test("when passed an array of duplicate numbers", () => { | ||
| expect(dedupe([1, 1, 2])).toEqual([1, 2]); | ||
| expect(dedupe([1, 1, 2, 2, 2, 3])).toEqual([1, 2, 3]); | ||
| expect(dedupe([1, 1, 1, 3, 3, 4, 4])).toEqual([1, 3, 4]); | ||
| }); | ||
|
|
||
| test("when passed an array of duplicate characters", () => { | ||
| expect(dedupe(["a", "a", "b", "b", "b", "c"])).toEqual(["a", "b", "c"]); | ||
| expect(dedupe(["c", "c", "e", "e", "z", "z"])).toEqual(["c", "e", "z"]); | ||
| }); |
There was a problem hiding this comment.
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.
| 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" | ||
| ); | ||
| }); |
There was a problem hiding this comment.
Well done. Good test cases coverage.
…-Groups into coursework/sprint-1
|
Thank you for your helpful advise. I have made the changes as advised. |
|
Well done to the fixes. Congratulation, you have completed this PR successfully. |
Learners, PR Template
Self checklist
Task code
CYF-1071
Changelist
I have completed all the tasks from Implementing functions to writing writing tests.
Questions