Manchester | 26-ITP-Jan | Mehroz Munir | Sprint 2 | Coursework#1051
Manchester | 26-ITP-Jan | Mehroz Munir | Sprint 2 | Coursework#1051MehrozMunir wants to merge 6 commits intoCodeYourFuture:mainfrom
Conversation
| // CASE 2: Should return an empty object if empty array is passed | ||
| test(`should return an empty object if the array is empty`, () => | ||
| expect(createLookup([[]])).toEqual({})); |
There was a problem hiding this comment.
The first argument is not quite an empty array; it is "an array containing an empty array".
For this input, your function actually returns { undefined: undefined } instead of {}, but toEqual() consider them equal because it ignores property named "undefined". A stricter comparison .toStrictEqual() would have flagged them as an error.
There was a problem hiding this comment.
Thanks.
Yes that is absolutely right. Do you think that I should always use toStrictEqual in all the test cases?
There was a problem hiding this comment.
Yes. I think .toStrictEqual() is better when comparing objects.
|
@cjyuan |
| .replace(/\s+/g, " "); | ||
|
|
||
| cleanText.split(" ").forEach((word) => { |
There was a problem hiding this comment.
Note: We can also use regex with .split(), and combine the operation on line 43 and 45 as:
cleanText.split(/\s+/).forEach((word) => {
|
@cjyuan Thank you for the feedback. I have made changes in mode.js, mode.test.js, and count-words.js files and pushed the latest code after your feedback. |
|
Changes look good. |
|
Closing PR because the January ITP run has finished. Feel free to re-open if you're still working on it. |
No description provided.