Skip to content

Birmingham | ITP Jan 2026 | Arunkumar Akilan | Sprint 2 | Data Groups#1027

Open
arunkumarakilan wants to merge 6 commits intoCodeYourFuture:mainfrom
arunkumarakilan:coursework/sprint2-clean
Open

Birmingham | ITP Jan 2026 | Arunkumar Akilan | Sprint 2 | Data Groups#1027
arunkumarakilan wants to merge 6 commits intoCodeYourFuture:mainfrom
arunkumarakilan:coursework/sprint2-clean

Conversation

@arunkumarakilan
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 bugs in address.js
  • Fixed bugs in author.js
  • Fixed bugs in recipe.js
  • Ensured all debug tests pass

⚙️ Implementation

  • Implemented tally function to count occurrences in an array
  • Implemented contains function to check if object has a property
  • Implemented createLookup function to convert key-value pairs into an object
  • Implemented parseQueryString with edge case handling
  • Implemented invert function to swap keys and values

🧪 Testing

  • Added unit tests for all functions
  • Covered edge cases (empty input, invalid input, multiple values, etc.)
  • All tests are passing

Notes

  • Used methods like Object.keys, Object.entries, and array iteration
  • Improved understanding of objects and key-value handling

Questions

No questions at the moment

@arunkumarakilan arunkumarakilan added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 17, 2026
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 ensure all the code is consistently formatted?
If you had successfully enabled "Format on save" and specified "Prettier" as your default JS formatter, you would not have this issue.

Comment on lines +31 to +35
test("Should throw an error for an invalid parameters", () => {
const object = [1,2,3,4,5,6,7];
const propertyName = "a";
expect(() => contains(object, propertyName)).toThrow();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Array is also an object where it indexes are its keys.
Object.hasOwn([1, 2, 3], "a") evaluates to false because "a" is not a key (index) of the array.
However, Object.hasOwn([1, 2, 3], "0") evaluates to true because "0" is a key (index) of the array.

To test if the implemented function can correctly return false when the first argument is an array,
we should specify an actual key of the array.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the clarification!

I understand that arrays are objects and that
Object.hasOwn([1, 2, 3], "0") returns true because "0" is a valid index.

However, in my implementation I explicitly treat arrays as invalid inputs:

if (typeof object !== "object" || Array.isArray(object) || object === null)

So the function throws an error before reaching Object.keys().
That’s why the test passes — it never evaluates array indexes like "0".

I’ll update either the test or the implementation depending on the expected behaviour

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not about your function, it is correctly implemented.

In practice, we prepare tests not just to check our implementation, but also to serve as a guard for future modification. In TDD, the tests will also serve as the spec that define how the function should be implemented.
That's why I keep emphasising the importance of preparing the tests correctly.

@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 Mar 22, 2026
@arunkumarakilan arunkumarakilan 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 Mar 23, 2026
@cjyuan
Copy link
Contributor

cjyuan commented Mar 23, 2026

Changes look good.

@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 Mar 23, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants