Skip to content

Sheffield | 26-ITP-Jan | Mahammad Osman | Sprint 1 | Sprint-1#1074

Open
Darkidd77 wants to merge 12 commits intoCodeYourFuture:mainfrom
Darkidd77:sprint-1
Open

Sheffield | 26-ITP-Jan | Mahammad Osman | Sprint 1 | Sprint-1#1074
Darkidd77 wants to merge 12 commits intoCodeYourFuture:mainfrom
Darkidd77:sprint-1

Conversation

@Darkidd77
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

Changelist

dedupe.js: Implemented array deduplication logic.

max.js: Refactored to use a functional pipeline (.filter() and Math.max with the spread operator ...) to safely ignore NaN and non-numeric strings.

sum.js: Implemented sum calculation using .reduce().

includes.js: Fixed a premature return bug inside the loop so the function correctly evaluates the entire array before returning false.

solution.js (Advent of Code): Built a data parsing pipeline using fs.readFileSync, .split('\n'), and .map(Number) to process a text file and calculate a final total using .reduce().

@Darkidd77 Darkidd77 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 22, 2026
@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 24, 2026
@Darkidd77 Darkidd77 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 2, 2026
Copy link
Copy Markdown
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.

Other changes look good.

Comment on lines +27 to +32
test("should return a copy of the original array when there are no duplicates", () => {
const input = [1, 2, 3];
expect(dedupe(input)).toEqual(input);

// Given an array of strings or numbers
// When passed to the dedupe function
// Then it should return a new array with duplicates removed while preserving the
// first occurrence of each element from the original array.
expect(dedupe(input)).not.toBe(input);
});
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.

There is a chance that, even though the returned value has incorrect elements (for example, [1, 1, 1]),
the two tests could still pass. Can you figure out why, and then fix the tests accordingly?

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.

Done! Yes, it's because this test could still pass even if the original array were destroyed or mutated in the function. It's a very interesting trap.
To fix it, I saved the output to a result variable and properly compared it against a hardcoded array. Thinking about TDD this deeply has been a great learning experience. Thank you

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 3, 2026
@Darkidd77 Darkidd77 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 6, 2026
@cjyuan
Copy link
Copy Markdown
Contributor

cjyuan commented Apr 6, 2026

All good! Well done.

@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. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Apr 6, 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