Skip to content

Conversation

@Iswanna
Copy link

@Iswanna Iswanna commented Nov 16, 2025

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

This pull request includes modifications to three directories:

Debug directory: I identified and fixed bugs in each file within the debug section by first predicting the issue, then running the code with Node to confirm the behaviour. All implementations were corrected so that they now pass the associated test cases.

Implement directory: I implemented functions based on the given requirements and ensured they work across a variety of inputs. I followed the recommended order (contains → lookup → tally → querystring) and created or updated corresponding test cases for each.

Interpret directory: I interpreted larger programs with unfamiliar syntax or operators using documentation and console logging. I refactored the implementations for clarity and reliability while ensuring all existing tests continued to pass.

Questions

Hi. Please could you review my PR? I’d really appreciate your feedback.

- returns true if object has property
- returns false if property missing or object empty
- throws TypeError for invalid inputs
@Iswanna Iswanna 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 Nov 16, 2025
Copy link
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.

Great work! Comprehensive tests!

I only have a few suggestions.

throw new TypeError("Invalid input: Input must be an array");
}

const result = {};
Copy link
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.

Copy link
Author

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.

No, it did not return the expected value.
expected value: {"toString": 2}
actual value: "toString": "function toString() { [native code] }11".

I would look up an approach to create an empty object with no inherited properties.

Comment on lines 12 to 23
const index = pair.indexOf("=");
let key, value;

if (index === -1) {
key = pair;
value = "";
} else {
key = pair.slice(0, index);
value = pair.slice(index + 1);
}
queryParams[key] = value;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

In real query string, both key and value are percent-encoded or URL encoded.
For example,

tags%5B%5D=hello%20world -> key is tags[], value is hello world

Can your function handle URL-encoded query string?

Suggestion: Look up "How to decode a URL-encoded string in JavaScript".

Comment on lines 59 to 79
expect(() => contains("hello", "location")).toThrow(
new TypeError("Invalid input: obj must be a plain object")
);
expect(() => contains(null, "a")).toThrow(
new TypeError("Invalid input: obj must be a plain object")
);
expect(() => contains(undefined, "a")).toThrow(
new TypeError("Invalid input: obj must be a plain object")
);
expect(() => contains(123, "a")).toThrow(
new TypeError("Invalid input: obj must be a plain object")
);
expect(() => contains(true, "a")).toThrow(
new TypeError("Invalid input: obj must be a plain object")
);
expect(() => contains([], "a")).toThrow(
new TypeError("Invalid input: obj must be a plain object")
);
expect(() => contains(() => {}, "a")).toThrow(
new TypeError("Invalid input: obj must be a plain object")
);
Copy link
Contributor

Choose a reason for hiding this comment

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

All these tests expect the same error to be thrown.
You could explore using Jest '.each' or similar approach to reduce redundant code.

Copy link
Author

Choose a reason for hiding this comment

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

I have refactored the test and pushed the changes to the remote repo

Comment on lines 17 to 19
for (const ingredient of recipe.ingredients) {
console.log(ingredient);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You may also like Array.prototype.join().

Copy link
Author

Choose a reason for hiding this comment

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

I have updated the code to use Array.prototype.join() instead of the loop I used before.

@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 Nov 21, 2025
@Iswanna
Copy link
Author

Iswanna commented Nov 21, 2025

Great work! Comprehensive tests!

I only have a few suggestions.

Thank you very much.

@Iswanna Iswanna 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 21, 2025
@Iswanna Iswanna requested a review from cjyuan November 21, 2025 19:11
Copy link
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.

Other changes look good.

Comment on lines 9 to 13

if (decodeURI(queryString) === decodeURIComponent(queryString)) {
queryString = decodeURIComponent(queryString);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

There may be special characters such as = and & encoded in the keys or values. If you decode the entire query string at this point, the = and & that are part of some keys or values will be mistaken for separators.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the feedback. I have fixed the code to decode after splitting.

@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 Nov 21, 2025
… and throw descriptive error for invalid URL encoding
@Iswanna Iswanna 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 21, 2025
@Iswanna Iswanna requested a review from cjyuan November 21, 2025 19:55
@cjyuan
Copy link
Contributor

cjyuan commented Nov 21, 2025

Great work!

@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 Nov 21, 2025
@Iswanna Iswanna closed this Nov 21, 2025
@Iswanna Iswanna reopened this Nov 21, 2025
@Iswanna
Copy link
Author

Iswanna commented Nov 21, 2025

Great work!

Thank you so much @cjyuan for reviewing my pull request and providing detailed feedback.

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.

3 participants