Skip to content

Cape Town| 26-ITP-May | Liyema Mfengwana| Sprint 2 | Data Groups - #1444

Open
LiyemaMfengwana wants to merge 18 commits into
CodeYourFuture:mainfrom
LiyemaMfengwana:sprint-2-work
Open

Cape Town| 26-ITP-May | Liyema Mfengwana| Sprint 2 | Data Groups#1444
LiyemaMfengwana wants to merge 18 commits into
CodeYourFuture:mainfrom
LiyemaMfengwana:sprint-2-work

Conversation

@LiyemaMfengwana

Copy link
Copy Markdown

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

Complete work

@LiyemaMfengwanaLiyemaMfengwana added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 20, 2026
Comment on lines +2 to +4
if (Array.isArray(object)) {
return false;
}

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.

Could you make this function to also return false when the first parameter is not an object? For examples, null, undefined, 1234, "ABCD".

Comment on lines 41 to +46
// Given invalid parameters like an array
// When passed to contains
// Then it should return false or throw an error
test("returns false for invalid input types", () => {
expect(contains([1, 2, 3], "propertyName")).toBe(false);
});

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 test could not yet confirm that the function correctly returns false when the first argument is an array.
This is because contains([1, 2, 3], "propertyName") could also return false simply because "propertyName" is not a key of the array.

The indices of an array acts as the keys of the array. A proper test should use a valid
key to ensure the function returns false specifically because the input is an array, not because the key is missing.

Comment on lines +5 to +9
const counts = {};

for (const item of items) {
counts[item] = (counts[item] || 0) + 1;
}

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.

Does the following function call returns the value you expect?

tally(["toString", "toString"]);

Suggestion:

  • Look up an approach to create an empty object with no inherited properties, or
  • use Object.hasOwn()

@cjyuancjyuan 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 Aug 20, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ReviewedVolunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@LiyemaMfengwana@cjyuan