Manchester | 26-ITP-Jan | Liban Jama | Sprint 2 | Data Groups #1050
Manchester | 26-ITP-Jan | Liban Jama | Sprint 2 | Data Groups #1050libanj0161 wants to merge 12 commits into
Conversation
|
Can you also respond to each comment to let me know what you did? |
cjyuan
left a comment
There was a problem hiding this comment.
Thanks for the clear explanations.
Changes look good.
I will mark this PR as complete first.
| @@ -1,3 +1,9 @@ | |||
| function contains() {} | |||
| function contains(object, propertyName) { | |||
| if (Object.prototype.toString.call(object) !== "[object Object]") { | |||
There was a problem hiding this comment.
This check will reject other kinds of objects such as Map and Set objects.
Can you change it to reject only arrays or any value that is not an object?
There was a problem hiding this comment.
Added a rejection for null and array, and added test.
Made contains work with map/set.
| if (object instanceof Map || object instanceof Set) { | ||
| return object.has(propertyName); | ||
| } |
There was a problem hiding this comment.
This is unnecessary because of the check on line 5.
| expect(contains(obj, "name")).toEqual(true); | ||
| }); | ||
|
|
||
| test("should throw an error when input is an array even if propertyName is a valid key", () => { |
There was a problem hiding this comment.
The function does not throw any error.
|
Closing PR because the January ITP run has finished. Feel free to re-open if you're still working on it. |
Learners, PR Template
Self checklist
Changelist
Completed Sprint 2 of Module Data Groups.
Questions
N/A.