Skip to content

London | 26-ITP-Jan | Miriam Jorna | Sprint 2 | Data Groups#1190

Open
miriamjorna wants to merge 5 commits intoCodeYourFuture:mainfrom
miriamjorna:DataGroupsSprint2
Open

London | 26-ITP-Jan | Miriam Jorna | Sprint 2 | Data Groups#1190
miriamjorna wants to merge 5 commits intoCodeYourFuture:mainfrom
miriamjorna:DataGroupsSprint2

Conversation

@miriamjorna
Copy link
Copy Markdown

@miriamjorna miriamjorna commented Apr 10, 2026

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

Coursework for Sprint 2.
My mojo went MIA but I've found it back!

@miriamjorna miriamjorna 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. Core This is a core task and should be completed by all trainees labels Apr 10, 2026
Comment on lines 42 to +47
// Given invalid parameters like an array
// When passed to contains
// Then it should return false or throw an error
test("given invalid parameters like an array, returns false", () => {
expect(contains([1, 2, 3], "a")).toEqual(false);
});
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.

Your function is correct, but we should prepare tests not only to verify our current implementation, but also to ensure that future changes do not alter the function's expected behavior.

This test cannot yet confirm that the function correctly returns false when the first argument is an array.
This is because contains([1, 2, 3], "a") could also return false simply because "a" is not a key of the array.

Arrays are objects, with their indices acting as keys. A proper test should use 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 +9 to +11
const index = pair.indexOf("=");
const key = pair.slice(0, index);
const value = pair.slice(index + 1);
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.

For each of the following function calls, does your function return the value you expect?
Note: These arguments are valid query strings.

parseQueryString("key1=value1&=&key2=value2")
parseQueryString("key=")                                   
parseQueryString("key1=value1&key2")
parseQueryString("=value")
parseQueryString("key1=value1&&key2=value2")

Comment on lines +5 to +12
const result = {};
for (const item of arr) {
if (result[item]) {
result[item]++;
} else {
result[item] = 1;
}
}
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() to check if result contains a specific key/item

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

Labels

Core This is a core task and should be completed by all trainees 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