Skip to content

London | 26-ITP-Sep | Shirin Panahian | Sprint 2| Complete sprint 2 exercises - #1516

Open
shirinpanahian wants to merge 8 commits into
CodeYourFuture:mainfrom
shirinpanahian:Sprint-2
Open

shirinpanahian wants to merge 8 commits into
CodeYourFuture:mainfrom
shirinpanahian:Sprint-2

Conversation

@shirinpanahian

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

Task code

CYF-1083

Changelist

This PR includes my work for Sprint 2 of the Module Data Groups project.

  • Debug: Analysed the existing code, predicted and explained the bugs, ran the files using Node.js, and fixed the issues.
  • Implement: Worked on implementing functions based on the provided requirements, including contains, lookup, tally, and querystring. Tested the functions with different inputs to verify their behaviour.
  • Interpret: Worked through the provided programs to understand unfamiliar JavaScript syntax, operators, and functions using documentation and console.log().

This sprint helped me improve my JavaScript problem-solving, debugging, implementation, and code-reading skills.

@shirinpanahian shirinpanahian added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 2 Assigned during Sprint 2 of this module labels Nov 12, 2026
@valentina-starr1

Copy link
Copy Markdown

Thank you for this PR. Great work completing the Sprint 2 exercises and adding tests.

I can see two small JavaScript edge cases to fix before merging:

tally.js (line 12): Plain objects inherit built-in keys like toString, so tally(["toString"]) tries to add 1 to a function instead of returning { toString: 1 }. Using Object.hasOwn() or Object.create(null) fixes this.

querystring.js (line 38): Assigning "proto" directly to a normal object changes its prototype instead of saving it as a key. Using Object.create(null) or Object.defineProperty() handles it safely.

@shirinpanahian

Copy link
Copy Markdown
Author

Thank you for the feedback and the helpful explanations!

I've fixed both edge cases using Object.hasOwn() in tally.js and Object.create(null) in querystring.js.

I've also added tests to cover these cases and pushed the updates to the PR.

Thanks again for the review!

Thank you for this PR. Great work completing the Sprint 2 exercises and adding tests.

I can see two small JavaScript edge cases to fix before merging:

tally.js (line 12): Plain objects inherit built-in keys like toString, so tally(["toString"]) tries to add 1 to a function instead of returning { toString: 1 }. Using Object.hasOwn() or Object.create(null) fixes this.

querystring.js (line 38): Assigning "proto" directly to a normal object changes its prototype instead of saving it as a key. Using Object.create(null) or Object.defineProperty() handles it safely.

@shirinpanahian shirinpanahian added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 12, 2026
@LonMcGregor LonMcGregor added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 16, 2026
if (Object.hasOwn(tallyObj, item)) {
tallyObj[item] = tallyObj[item] + 1;
} else {
tallyObj[item] = 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What own property does the {} accumulator get when an input item is "__proto__"? Try tally(["__proto__"]) and compare the result with the requirement to count every item.

To "like" or "dislike" this comment, please follow this link

Comment on lines +8 to +13
console.log(
createLookup([
["US", "USD"],
["CA", "CAD"],
])
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What appears in the test process output when lookup.test.js requires this module?

To "like" or "dislike" this comment, please follow this link

Comment on lines +43 to +46
test("given an object, returns true as the object contains a key of 'a'", function () {
const input = contains({ a: 1, b: 2 }, "c");
const currentOutput = input;
const targetOutput = false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How do the descriptions for the "c", numeric, null, and missing-argument cases compare with their inputs and assertions?

To "like" or "dislike" this comment, please follow this link

Comment thread Sprint-2/debug/author.js
console.log(author[value]);
}
//author is Object and it is not iterable
//for...of loop excepts array and string but it not working with object type

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Besides arrays and strings, what other iterable types can a for...of loop handle?

To "like" or "dislike" this comment, please follow this link

@cyf-ai-code-reviewer cyf-ai-code-reviewer Bot 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 Nov 16, 2026
@cyf-ai-code-reviewer

Copy link
Copy Markdown

The CYF AI review has left comments. It will only review a PR one time. When you have addressed these comments, please request review again and a volunteer will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants