Skip to content

West-Midlands | 26-ITP-May | Maryam Janjua | Sprint 2 | Sprint 2 Exercises - #1433

Open
maryam-devio wants to merge 4 commits into
CodeYourFuture:mainfrom
maryam-devio:dataGroup-Sprint2
Open

West-Midlands | 26-ITP-May | Maryam Janjua | Sprint 2 | Sprint 2 Exercises#1433
maryam-devio wants to merge 4 commits into
CodeYourFuture:mainfrom
maryam-devio:dataGroup-Sprint2

Conversation

@maryam-devio

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 attempted all the exercises according to the requirements. I debugged the code, completed the tasks, and tested my solutions to make sure they work as expected.

@maryam-devio maryam-devio 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 Aug 14, 2026
Comment thread Sprint-2/debug/recipe.js Outdated
Comment on lines +5 to +12
let getKey = Object.keys(obj);
for (let element of getKey){
if(element === item){
return true
}
}
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.

This works.

Do check out Object.hasOwn() and also
use AI to find out the trade-off among different ways to check if an object contains a particular key.

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! I checked Object.hasOwn(). I could simplify my function by using Object.hasOwn(obj, item) instead of getting all the keys and looping through them. It also checks only the object's own properties, which fits this function well. I'll also look into the trade-offs between Object.hasOwn(), in, and hasOwnProperty().

Comment thread Sprint-2/implement/contains.test.js Outdated
Comment on lines +45 to +47
test("return false if it's not an object", () => {
expect(contains([], 6)).toBe(false);
}); No newline at end of file

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.

When a function does not test if the first argument is an array, contains([], 6) could also return false simply because 6 is not a key of the empty array.

A proper test should use a non-empty array along with a valid
key to ensure the function returns false specifically because the first argument 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, that makes sense. Using an empty array could return false simply because the key doesn't exist. I've changed the test to use a non-empty array with an existing key so it specifically checks that arrays are rejected.

key = decodeURIComponent(key);
value = decodeURIComponent(value);

if (Object.prototype.hasOwnProperty.call(queryParams, 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.

Could also use Object.hasOwn().

Comment thread Sprint-2/implement/tally.js
@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 14, 2026
@maryam-devio maryam-devio 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 Aug 20, 2026

@cjyuan cjyuan left a comment

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.

Changes look good.

Thanks for being so thorough with the review feedback and making sure every comment was addressed.

Excellent job!

@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. labels Aug 20, 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