Skip to content

London | 26-ITP-May | Dagim Daniel | Sprint 2 | All Section Exercises - #1362

Open
Dagim-Daniel wants to merge 6 commits into
CodeYourFuture:mainfrom
Dagim-Daniel:Sprint-2/coursework
Open

London | 26-ITP-May | Dagim Daniel | Sprint 2 | All Section Exercises#1362
Dagim-Daniel wants to merge 6 commits into
CodeYourFuture:mainfrom
Dagim-Daniel:Sprint-2/coursework

Conversation

@Dagim-Daniel

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

i have completed all section tasks under Sprint 2, but i have commited separetly in this PR

@Dagim-Daniel Dagim-Daniel added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Data-Groups The name of the module. Core This is a core task and should be completed by all trainees and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 2, 2026
Comment on lines +19 to +21
test("Give invalid parameter in this case array when passed to contains it returns false", () => {
expect(contains(["a", 2, "b", 3, 2], 2)).toEqual(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.

Should values like null, undefined, 1234, true, "ABC" be considered as invalid first parameter as well?

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.

// Given invalid parameters like an array
// When passed to contains
// Then it should return false or throw an error this were the question that's why i make it 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.

// Given invalid parameters like an array

That means "array" is just one possible kind of invalid parameters. There could be others.

Comment thread Sprint-2/implement/contains.test.js Outdated
Comment on lines +5 to +8
const result = {};
for (const item of items) {
result[item] = (result[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()

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.

it function as expected let say console.log (tally(["a","a","b","a","c"]) ==> {a:3, b:1,c:1}

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.

may be i don't understand your questions, could you explain your question a little bit sorry

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.

Have you tried calling the function with this exact argument?

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

@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 Aug 10, 2026
@Dagim-Daniel Dagim-Daniel added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 10, 2026
@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 10, 2026
@Dagim-Daniel Dagim-Daniel added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 11, 2026
@cjyuan

cjyuan commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Changes look good.

@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 Aug 11, 2026
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. Core This is a core task and should be completed by all trainees Module-Data-Groups The name of the module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants