Skip to content

London | 26-ITP-May | Damilola Odumosu | Sprint 2 | Coursework - #1352

Open
d-odumosu wants to merge 9 commits into
CodeYourFuture:mainfrom
d-odumosu:coursework/sprint-2
Open

London | 26-ITP-May | Damilola Odumosu | Sprint 2 | Coursework#1352
d-odumosu wants to merge 9 commits into
CodeYourFuture:mainfrom
d-odumosu:coursework/sprint-2

Conversation

@d-odumosu

Copy link
Copy Markdown

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

  • debug
  • implement
  • interpret

@d-odumosu d-odumosu 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. 📅 Sprint 2 Assigned during Sprint 2 of this module labels Jul 31, 2026
Comment thread Sprint-2/debug/author.js
console.log(value);
//An object is not directly iterable, if we want to log out the values we can use a for in loop
for (const value in author) {
console.log(`${author[value]}`);

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.

Why not just call the function asconsole.log(author[value]) ?

Comment thread Sprint-2/debug/recipe.js
ingredients:
${recipe}`);
ingredients:`);
for (const value of Object.values(recipe.ingredients)) {

@cjyuan cjyuan Aug 5, 2026

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.

Why not use the for-of loop to iterate through the array recipe.ingredients directly? That is, without Object.values().

Comment on lines +2 to +4
if (Array.isArray(object)) {
throw new Error("Expected an object, received an array");
}

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.

What if object is null, undefined, 1234, true, or "1234"?

Comment on lines +5 to +9
const obj = Object.keys(object);
if (obj.length === 0) {
return false;
}
return obj.includes(property);

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. Could also explore Object.hasOwn()

Comment on lines +76 to +77
const arr = [];
const propertyNameCheck4 = "name";

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.

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.

Comment on lines 14 to 19
test("should ignore empty key-value pairs", () => {
expect(parseQueryString("key1=value1&&key2=value2&")).toEqual({
key1: "value1",
key2: "value2",
});
});

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 your function pass this test?

queryParams[key] = value;
const indexOfFirst = pair.indexOf("=");
if (indexOfFirst === -1) {
queryParams[pair] = "";

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.

Note: The value of pair has not yet been decoded.

return arr.reduce((acc, cur) => {
acc[cur] = (acc[cur] || 0) + 1;
return acc;
}, {});

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()

@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 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Data-Groups The name of the module. 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.

2 participants