Skip to content

Conversation

@Tarawally
Copy link

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

  • Debug: Fixed property access in address.js, author.js, and recipe.js
  • Implement: Added contains, lookup, tally, and querystring functions with tests
  • Interpret: Answered questions and fixed invert.js

@Tarawally Tarawally added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 29, 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.

Can you revert the changes made in the "Sprint-3" folder to keep this branch clean?


// Handles invalid inputs gracefully
test("contains handles invalid parameters", () => {
expect(contains([], "a")).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Arrays are objects in JavaScript, and they do have property names -- just not the same ones as objects.
Which keys do arrays have, and how does that affect how reliable your test is?

When testing whether the function handles arrays properly, try using a key that an array might
realistically contain
. Otherwise, you might get a passing test even if the function isn't checking for arrays at all.

Comment on lines +9 to +11
for (const pair of arrayOfPairs) {
const key = pair[0];
const value = pair[1];
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also consider using array destructuring to simplify this 3 lines of code.

Comment on lines +19 to +22
const firstEqualsIndex = pair.indexOf("=");

const key = pair.slice(0, firstEqualsIndex);
const value = pair.slice(firstEqualsIndex + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the query string is "key1&key2" (i.e., without =)?

const key = pair.slice(0, firstEqualsIndex);
const value = pair.slice(firstEqualsIndex + 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".

throw new Error("Input must be an array");
}

const countObject = {};
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.

@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 29, 2025
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants