Skip to content

London | 26-ITP-May | Alex Jamshidi | Sprint 1 | Exercises #1225

Open
Alex-Jamshidi wants to merge 9 commits into
CodeYourFuture:mainfrom
Alex-Jamshidi:Sprint-1
Open

London | 26-ITP-May | Alex Jamshidi | Sprint 1 | Exercises #1225
Alex-Jamshidi wants to merge 9 commits into
CodeYourFuture:mainfrom
Alex-Jamshidi:Sprint-1

Conversation

@Alex-Jamshidi
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

Sprint-1 exercises completed

@Alex-Jamshidi Alex-Jamshidi added 📅 Sprint 1 Assigned during Sprint 1 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 May 12, 2026
Copy link
Copy Markdown
Member

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

LGTM, a few things to look at

Comment thread Sprint-1/implement/dedupe.test.js Outdated
{ input: ["hello", "a", "b", "c"], expected: ["hello", "a", "b", "c"] },
{ input: [1, 2, "hello", 4, "a", 6], expected: [1, 2, "hello", 4, "a", 6] },
].forEach(({ input, expected }) =>
it(`returns the median for [${input}]`, () => expect(dedupe(input)).toEqual(expected))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't test one of the parts of the wording of the comment above, that it returns a copy of the original array. How could you test that the array returned is a copy, rather than the same array that was passed in?

Copy link
Copy Markdown
Author

@Alex-Jamshidi Alex-Jamshidi May 15, 2026

Choose a reason for hiding this comment

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

I fixed this with this addition to the test:

it(`returns a non-identical array (copy) for [${input}]`, () =>
  expect(dedupe(input)).not.toBe(input));

Where the input of the test is being passed to the dedupe function and the return of that is compared with the original input and checked 'not.toBe' the same

tests pass

Comment thread Sprint-1/implement/max.js Outdated
function findMax(list) {
const numbers = list.filter((n) => Number.isFinite(n));
if (numbers.length == 0) {
return "-Infinity";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You always want to return a number here not a string. Infinity is a special numeric literal in JavaScript - it's a number like others (but a bit special).

Suggested change
return "-Infinity";
return -Infinity;

If you put the term in quotes, you're returning a string, not a number.

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.

ah okay! thanks, updated

Comment thread Sprint-1/implement/max.test.js Outdated

it("empty array returns -Infinity", () => {
const list = [];
expect(findMax(list)).toEqual("-Infinity");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
expect(findMax(list)).toEqual("-Infinity");
expect(findMax(list)).toEqual(-Infinity);

Comment thread Sprint-1/implement/max.test.js Outdated

it("array with only non-number values, return the least surprising value given how it behaves for all other inputs", () => {
const list = ["a", "b", "c"];
expect(findMax(list)).toEqual("-Infinity");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
expect(findMax(list)).toEqual("-Infinity");
expect(findMax(list)).toEqual(-Infinity);

@illicitonion illicitonion 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 May 15, 2026
@Alex-Jamshidi Alex-Jamshidi 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 May 15, 2026
@illicitonion illicitonion 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 May 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 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants