Skip to content

Conversation

@HilolaRustam
Copy link

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@HilolaRustam HilolaRustam 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. labels Jul 12, 2025
@AdnanGondal AdnanGondal self-requested a review July 19, 2025 10:58
@AdnanGondal AdnanGondal 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 Jul 19, 2025

Choose a reason for hiding this comment

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

Great explanations and solutions for the debug section - well done.

Choose a reason for hiding this comment

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

Perhaps it would be better to add different edge cases to these tests such as what happens when:

  • Empty input
  • When there are duplicate keys
  • When a pair has extra values, such as createLookup([["UK", "GBP", "Extra"]])).

Copy link
Author

Choose a reason for hiding this comment

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

i added some more test cases.

Copy link
Member

Choose a reason for hiding this comment

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

These tests are really interesting - it feels like there are three things we could do with ["UK", "GBP", "Extra"]:

  1. Ignore the "Extra"
  2. Ignore the whole entry because it's not in the expected format
  3. Throw an error because the caller probably didn't something wrong and we want to tell them there's a problem

Why did you pick 1? How do you feel about 2 and 3?

Copy link
Author

Choose a reason for hiding this comment

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

I thought 1 is flexible and tolerant of inputs with extra data.
2 would not be so helpful as it would ignore the data and not alert the data issue.
And 3 would be the choice if this function was part of a stricter API where input validation is important to make sure data issues are caught early.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, 1 vs 3 both sound pretty reasonable. There are trade-offs between ignoring potentially bad data vs erroring. e.g. imagine if someone had intentionally passed three values because a country had two currencies:

["ZW", "ZiG", "USD"]

If we proactively error, we tell them "Our system only supports two currencies, we're ignoring one of the ones you passed, you probably don't want to pass two, pick one". By not erroring, developers may assume their code is working with multiple currencies, when really some is being ignored.

Choose a reason for hiding this comment

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

A great set of test cases. Just had one question.
What do you expect to happen when you run parseQueryString("a=1&&b=2").
Can you add a test case for it?

Copy link
Author

Choose a reason for hiding this comment

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

test is going to look like this.
test("parses multiple key-value pairs", () => {
expect(parseQueryString("a=1&&b=2")).toEqual({ a: "1", "", b: "2" });
});

Copy link

@AdnanGondal AdnanGondal left a comment

Choose a reason for hiding this comment

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

A great submission - but I have added some comments regarding additional test cases. Once done, let me know and I will mark as Complete.

@AdnanGondal AdnanGondal 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 Jul 19, 2025
@HilolaRustam HilolaRustam 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 Jul 25, 2025
Copy link
Member

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

This is looking really good - just a couple of small comments :)

queryParams[key] = value;
}
const [key, ...rest] = pair.split("="); // Grab everything after first '='
const value = rest.join("="); // Safely join back if value had '=' signs
Copy link
Member

Choose a reason for hiding this comment

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

This joining logic is really useful, but if you removed it none of your tests would start failing. Could you add a test that shows why this logic is here?

Copy link
Author

Choose a reason for hiding this comment

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

i did, thank you

Copy link
Member

Choose a reason for hiding this comment

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

These tests are really interesting - it feels like there are three things we could do with ["UK", "GBP", "Extra"]:

  1. Ignore the "Extra"
  2. Ignore the whole entry because it's not in the expected format
  3. Throw an error because the caller probably didn't something wrong and we want to tell them there's a problem

Why did you pick 1? How do you feel about 2 and 3?

@illicitonion illicitonion 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 13, 2025
@HilolaRustam HilolaRustam 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 Aug 13, 2025
@illicitonion illicitonion 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 Aug 14, 2025
@github-actions

This comment was marked as resolved.

1 similar comment
@github-actions

This comment was marked as resolved.

@illicitonion illicitonion changed the title London | May-2025 | KhilolaRustamova |Mdg/sprint 2 London | May-2025 | KhilolaRustamova | Sprint 2 | Sprint 2 coursework Aug 14, 2025
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. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants