Skip to content

Manchester | 26-ITP-Jan | Liban Jama | Sprint 2 | Data Groups #1050

Open
libanj0161 wants to merge 12 commits intoCodeYourFuture:mainfrom
libanj0161:Data-Groups-Sprint-2
Open

Manchester | 26-ITP-Jan | Liban Jama | Sprint 2 | Data Groups #1050
libanj0161 wants to merge 12 commits intoCodeYourFuture:mainfrom
libanj0161:Data-Groups-Sprint-2

Conversation

@libanj0161
Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Completed Sprint 2 of Module Data Groups.

Questions

N/A.

@libanj0161 libanj0161 added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Data-Groups The name of the module. labels Mar 19, 2026
@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 25, 2026
@libanj0161 libanj0161 requested a review from cjyuan March 26, 2026 12:52
@libanj0161 libanj0161 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 26, 2026
@cjyuan
Copy link
Copy Markdown
Contributor

cjyuan commented Mar 26, 2026

Can you also respond to each comment to let me know what you did?

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 26, 2026
@libanj0161 libanj0161 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 26, 2026
Copy link
Copy Markdown
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a rejection for null and array, and added test.
Made contains work with map/set.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 26, 2026
@libanj0161 libanj0161 requested a review from cjyuan March 27, 2026 11:12
@libanj0161 libanj0161 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 27, 2026
Comment on lines +2 to +4
if (object instanceof Map || object instanceof Set) {
return object.has(propertyName);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary because of the check on line 5.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed check for map/set

expect(contains(obj, "name")).toEqual(true);
});

test("should throw an error when input is an array even if propertyName is a valid key", () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function does not throw any error.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated test description

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 27, 2026
@libanj0161 libanj0161 requested a review from cjyuan March 27, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Data-Groups The name of the module. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants