Repository navigation
Manchester | 26-ITP-Sep | Mathew Shaibu | Sprint 1 | Module data groups sprint-1 - #1480
MattCarolus10 wants to merge 63 commits into
Conversation
| // Given an array with no duplicates | ||
| // When passed to the dedupe function | ||
| // Then it should return a copy of the original array |
There was a problem hiding this comment.
-
You missed implementing this test.
-
Please note that in this test, in addition to checking the returned array has the same elements, you should also test whether the returned array is a different array.
| // Given an array of strings or numbers | ||
| // When passed to the dedupe function | ||
| // Then it should return a new array with duplicates removed while preserving the | ||
| // first occurrence of each element from the original array. | ||
| test("keeps the first occurrence order", () => { | ||
| expect(dedupe([5, 1, 1, 2, 3, 2, 5, 8])).toEqual([5, 1, 2, 3, 8]); | ||
| }); |
There was a problem hiding this comment.
-
The comment on line 25 suggests testing an array containing mixed types of values.
-
We could test multiple test cases in one test, and doing so gives us a better chance to catch bugs.
-
I would also suggest using AI to research what would make good test cases and, more importantly, why. There may be valuable reasoning and insights that we can learn from AI. In fact, understanding the "why" is more important than simply identifying the "what". (This applies to all tests in this exercise)
| if (!Array.isArray(list)) { | ||
| throw new Error("sum requires an array of numbers"); | ||
| } | ||
| if (!list.every((item) => typeof item === "number")) { |
There was a problem hiding this comment.
+/- Infinity and NaN are also of type "number". If it were up to you, how would you design the function to handle these values?
| @@ -0,0 +1,16 @@ | |||
| const fs = require("fs"); | |||
| const changes = fs.readFileSync("input.txt", "utf8").trim().split("\n").map(Number); | |||
There was a problem hiding this comment.
Could you walk me through why trim() is needed before applying split("\n") on the input?
| if (seen.has(frequency)) { | ||
| console.log(frequency); | ||
| break; | ||
| } | ||
| seen.add(frequency) |
|
Could you prepare and format the PR description following the same structure and style as the example in this PR? |
No description provided.