Skip to content

London | 26-ITP-May | Alex Jamshidi | Sprint 2 | Exercises#1226

Open
Alex-Jamshidi wants to merge 16 commits into
CodeYourFuture:mainfrom
Alex-Jamshidi:Sprint-2
Open

London | 26-ITP-May | Alex Jamshidi | Sprint 2 | Exercises#1226
Alex-Jamshidi wants to merge 16 commits into
CodeYourFuture:mainfrom
Alex-Jamshidi:Sprint-2

Conversation

@Alex-Jamshidi
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 exercises for Sprint 2

@Alex-Jamshidi Alex-Jamshidi 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 May 13, 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.

Some of the code is not consistently formatted or indented.

Have you installed the prettier VSCode extension and enabled "Format on save/paste" on VSCode, as recommended in
https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/blob/main/readme.md
?

Comment thread Sprint-2/debug/address.js Outdated
Comment thread Sprint-2/implement/contains.js Outdated
Comment thread Sprint-2/implement/contains.test.js Outdated
Comment on lines +50 to +53
it("given invalid parameter (an array) returns false or throws an error", () => {
const object = [];
const property = [];
expect(contains(object, property)).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.

Your function can correctly return false when the first argument is an array.

However, we write tests not only to verify our current implementation, but also to ensure that future changes do not alter the function's expected behavior.

The current test cannot yet confirm the function can correctly return false when the first argument is an array
because contains([], []) could also return false simply because [] is not a key of the array.

Arrays are objects, with their indices acting as keys. A proper test should use a non-empty array along with a valid key to ensure the function returns false specifically because the input is an array, not because the key is missing.

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.

Thanks for this, I understand.

I wrote several tests to cover all options for arrays (filled or empty).

Comment thread Sprint-2/implement/lookup.js Outdated
Comment thread Sprint-2/implement/querystring.js Outdated
Comment thread Sprint-2/implement/querystring.js Outdated
Comment thread Sprint-2/implement/tally.js Outdated
@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 May 13, 2026
Comment thread Sprint-2/implement/contains.test.js Outdated
Comment on lines +51 to +54
expect(contains([], [])).toEqual(false);
expect(contains(["a", 1], "a")).toEqual(false);
expect(contains({ a: 1, b: 2 }, ["a"])).toEqual(false);
expect(contains(["a", 1], ["a"])).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.

"a" and ["a"] are not keys of ["a", "1"], but "0" and "1" are. You should use either "0" or "1" as key to ensure the function returns false because the first parameter is an array.

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 and rerun tests to pass

Comment thread Sprint-2/implement/querystring.js Outdated
}

// Adds percentage-encoded characters
queryString = decodeURIComponent(queryString);
Copy link
Copy Markdown
Contributor

@cjyuan cjyuan May 14, 2026

Choose a reason for hiding this comment

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

If you decode the characters so early and some the decoded characters are '=', '+', or '&', the query will be incorrectly parsed.

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 this to resolve decoded chars at the end
refactored code to make more clear

@cjyuan
Copy link
Copy Markdown
Contributor

cjyuan commented May 14, 2026

Don't forget to add the "Needs Review" label back whenever your PR is ready to be re-reviewed. Your other changes look good and thanks for responding to each comment.

@Alex-Jamshidi Alex-Jamshidi added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels May 14, 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.

Changes look good. Well done!

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label May 15, 2026
@cjyuan cjyuan added the Complete Volunteer to add when work is complete and all review comments have been addressed. label May 15, 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. 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