Skip to content

Glasgow | 26-ITP-May | Sandani Kannangara | sprint 2 | Data groups - #1236

Open
SandzSoft wants to merge 19 commits into
CodeYourFuture:mainfrom
SandzSoft:data-groups/sprint-2
Open

Glasgow | 26-ITP-May | Sandani Kannangara | sprint 2 | Data groups#1236
SandzSoft wants to merge 19 commits into
CodeYourFuture:mainfrom
SandzSoft:data-groups/sprint-2

Conversation

@SandzSoft

Copy link
Copy Markdown

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

Implemented and tested data group functions including tally, invert, lookup, parseQueryString, calculateMode, and totalTill.

Added Jest tests covering normal cases and edge cases, including invalid inputs. Refactored calculateMode into smaller functions and fixed issues with object handling, query string parsing, and frequency counting.

@SandzSoft SandzSoft 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. labels Jul 7, 2026

@LonMcGregor LonMcGregor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good work on these tasks, I've left some extra comments for things you could improve.

Comment thread Sprint-2/debug/recipe.js Outdated
};

console.log(`${recipe.title} serves ${recipe.serves} ingredients:`);
recipe.ingredients.forEach((ingredient) => console.log(ingredient));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As a stretch - there is a way to write this last line without an anonymous function. Can you figure it out?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi Leon, Do you mean using a for loop for an array like this,
for (let ingredient of recipe.ingredients) {
console.log(ingredient);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If you want to use array.forEach, there is a way to tell it to use a function, without needing to write => - can you figure out how? It can improve readability a lot.

@SandzSoft SandzSoft Jul 14, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I tried recipe.ingredients.forEach(console.log). It removes the anonymous function, but it also prints the index and the array because forEach passes three arguments. Was this the approach you were hinting at, or is there another function-reference pattern you had in mind?

I updated my code with separate print function.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That's exactly the approach I was thinking of. Whenever you have a function that just calls another function it's usually a good indicator you can simplify things

Comment thread Sprint-2/implement/querystring.js Outdated
Comment thread Sprint-2/implement/querystring.js
@LonMcGregor LonMcGregor 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 Jul 13, 2026
@SandzSoft SandzSoft 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 13, 2026
@SandzSoft SandzSoft added Core This is a core task and should be completed by all trainees and removed Core This is a core task and should be completed by all trainees labels Jul 13, 2026
@SandzSoft SandzSoft added Core This is a core task and should be completed by all trainees and removed Core This is a core task and should be completed by all trainees labels Jul 13, 2026
@LonMcGregor LonMcGregor 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 Jul 14, 2026
@SandzSoft SandzSoft added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 14, 2026
@SandzSoft SandzSoft removed the Reviewed Volunteer to add when completing a review with trainee action still to take. label Jul 14, 2026

@LonMcGregor LonMcGregor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This works. Just be aware that if you only needed a function to do one thing, you can call it directly in forEach. Of course, having a separate function like this is a bit more maintainable if you wanted to change how things were printed later on. Good work on this task.

Comment thread Sprint-2/implement/querystring.js Outdated
Comment thread Sprint-2/implement/querystring.js
Comment thread Sprint-2/debug/recipe.js Outdated
};

console.log(`${recipe.title} serves ${recipe.serves} ingredients:`);
recipe.ingredients.forEach((ingredient) => console.log(ingredient));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That's exactly the approach I was thinking of. Whenever you have a function that just calls another function it's usually a good indicator you can simplify things

@LonMcGregor LonMcGregor 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 Jul 15, 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. Module-Data-Groups The name of the module. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants