Skip to content

Cape Town | 26-ITP-Sept | Leigh Ross | Sprint 2 | Coursework sprint 2 - #1503

Open
leigh-ross wants to merge 10 commits into
CodeYourFuture:mainfrom
leigh-ross:coursework/sprint-2
Open

leigh-ross wants to merge 10 commits into
CodeYourFuture:mainfrom
leigh-ross:coursework/sprint-2

Conversation

@leigh-ross

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

Sprint 2 changes:

  • Implemented: contains, createLookup, parseQueryString, tally, invert
  • invert: added non-object error handling + bracket-notation swap
  • Added tests for all functions and all pass
  • Predict-and-explain write-ups: object-to-string, for...in, dot notation

leigh-ross and others added 10 commits November 6, 2026 00:23
…ingle object with key value pairs (each array being a k-v pair). Implemented test. Test passes. Using Object method
…an object with key and value pairs, using guidance from already written test cases. All tests pass
…cy of each item then returns an object with each item-frequency pair. Implemented tests and all tests pass.
…d bracket notation to assign propeties which handles swopping key-value pairs. Added test file and tests. all tests pass
@leigh-ross leigh-ross added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 11, 2026

@cjyuan cjyuan left a comment

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 you use prettier to format the code in all files to keep the code consistently formatted?

Comment on lines 53 to +62
// Given a value that isn't an object - an array, a string, a number,
// null, or no argument at all
// When passed to contains
// Then it should throw Error("contains requires an object")
// (careful: typeof [] and typeof null are both "object")
test("given: value that is not an object throws error: 'contains requires an object'", () => {
const input = "tooth";
const key = 'k'
expect(() => contains(input, key)).toThrow("contains requires an object")
}); No newline at end of file

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 you also test arrays and other non-object values?

for (const pair of keyValuePairs) {
const [key, value] = pair.split("=");
queryParams[key] = value;
let keyValuePair = keyValuePairs;

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.

The name keyValuePair does not clearly convey how the value stored in keyValuePair differs from the value stored in keyValuePairs.

Comment on lines +8 to +15
if (queryString.includes("+")) {
keyValuePair = keyValuePairs.map((keyValuePair) =>
keyValuePair.replaceAll("+", " ")
);
} else if(queryString.includes("%")) {
keyValuePair = keyValuePairs.map((keyValuePair) =>
decodeURIComponent(keyValuePair))
};

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.

  • A key or value could contain both + and percent-encoded characters. They are not exclusive.

  • If you decode the percent-encoded characters here, then the function would not correctly decode a%3Db=x+y to { 'a=b': 'x y' }.

@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 16, 2026
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