Skip to content

London | 26-ITP-Sep | Chandramani Gaire | Sprint 2 | Module-Data-Group - #1515

Open
gaireprakash20-ops wants to merge 22 commits into
CodeYourFuture:mainfrom
gaireprakash20-ops:Sprint-2
Open

gaireprakash20-ops wants to merge 22 commits into
CodeYourFuture:mainfrom
gaireprakash20-ops:Sprint-2

Conversation

@gaireprakash20-ops

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

I have done all the course work and created new file for the Invert.js ans have pushed it along with the rest of file

@github-actions

This comment has been minimized.

@gaireprakash20-ops gaireprakash20-ops changed the title Sprint 2London | 26-ITP-Sep | Chandramani Gaire | Sprint 1 | Module-Data-Group London | 26-ITP-Sep | Chandramani Gaire | Sprint 2 | Module-Data-Group Nov 11, 2026
@gaireprakash20-ops gaireprakash20-ops added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 11, 2026

@gaireprakash20-ops gaireprakash20-ops left a comment

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.

please review this file

@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
Comment thread Sprint-2/implement/querystring.js Outdated
Comment on lines +21 to +25
if (decodedKey in queryParams) {
if (Array.isArray(queryParams[decodedKey])) {
queryParams[decodedKey].push(decodedValue);
} else {
queryParams[decodedKey] = [queryParams[decodedKey], decodedValue];

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 happens when a query string contains a key such as toString or __proto__? Does in here distinguish keys already parsed from properties inherited by queryParams?

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

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.

I replaced the empty object {} with Object.create(null) to prevent inherited properties such as toString and proto. I replaced the in operator with Object.hasOwn() to check only properties that belong directly to the object. These changes make the query-string parser safer and handle special keys more reliably.

Comment on lines +27 to +29
test("contains on empty object returns false", () => {
expect(contains({}, "name")).toBe(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.

Now that this case has an implementation test, what will Jest still report from the earlier test.todo? The same leftover TODO is present in lookup.test.js.

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

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.

i remove the TODO from lookup.test.js

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please also remove the TODO from this file as well. Otherwise, Jest library would still not showing a pass. Thank you.

Comment thread Sprint-2/interpret/invert.js Outdated
// ==>It turns an object into an array of [key, value] pairs. Object.entries({ a: 1, b: 2 }) gives [["a", 1], ["b", 2]]. It’s needed because a for...of loop can’t go through a plain object directly, and the function needs both the key and the value of each property. Object.entries provides both, and const [key, value] unpacks each pair.
// d) Explain why the current return value is different from the target output

// ==>first it used the dot notation instead of square bracket which is accessing the property using a literal name

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does the issue with invertedObj.key come from dot notation itself, or from which property name that expression accesses?

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

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.

explain why the current return value is different from the target output

@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.

@gaireprakash20-ops gaireprakash20-ops 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 Nov 17, 2026
@hackertainment hackertainment added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 21, 2026

@hackertainment hackertainment left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I can see that you have a strong sense of edge cases. Just need to clear the concept between object and prototype. Maybe book a mentored coding session with a volunteer if that helps. You are almost there and just a minor fix. Please keep it up. Thank you.

Comment on lines +27 to +29
test("contains on empty object returns false", () => {
expect(contains({}, "name")).toBe(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.

Please also remove the TODO from this file as well. Otherwise, Jest library would still not showing a pass. Thank you.

Comment thread Sprint-2/implement/tally.js Outdated
for (const item of items) {
const key = String(item);

if (Object.prototype.hasOwnProperty.call(counts, key)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In the future, try to avoid manipulate the prototype directly as it may create side effect to objects of the same type (which could make the code harder to maintain). Your statement is actually the same as if (counts.hasOwnProperty(key)) { which just touches the object but not prototype.

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.

Delete the todo file line 26 and and Use Object.hasOwn instead of Object.prototype.hasOwnProperty for better readability

Comment thread Sprint-2/implement/tally.js Outdated
Comment on lines +14 to +19
Object.defineProperty(counts, key, {
value: 1,
writable: true,
enumerable: true,
configurable: true,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This code segment also directly access the prototype. You may just need counts[key] = 1; so that it just touches the object but not prototype.

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.

Remove the use of object

Comment on lines +81 to +93
test("tally counts numbers and booleans by their string form", () => {
expect(tally([1, 1, 2, true, true])).toEqual({ 1: 2, 2: 1, true: 2 });
});

test("tally treats different cases as different items", () => {
expect(tally(["a", "A", "a"])).toEqual({ a: 2, A: 1 });
});

test("tally does not change the array it is given", () => {
const input = ["a", "b", "a"];
tally(input);
expect(input).toEqual(["a", "b", "a"]);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Very good coverage for having these 3 test cases.

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

Comment on lines +40 to +43
test("inverting twice gives back the original when values are unique strings", () => {
const original = { a: "x", b: "y" };
expect(invert(invert(original))).toEqual(original);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Interesting test case, very good!

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 you

@hackertainment hackertainment added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Nov 21, 2026

@gaireprakash20-ops gaireprakash20-ops left a comment

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.

i did all review question

@gaireprakash20-ops gaireprakash20-ops 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 Nov 23, 2026
@hackertainment

Copy link
Copy Markdown

Congratulation, you have completed this PR successfully.

@hackertainment hackertainment 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 Nov 23, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants