Skip to content

London | 26-ITP-May | Vito Moratti | Sprint 1 | Module data groups/sprint1 - #1297

Open
vmoratti wants to merge 28 commits into
CodeYourFuture:mainfrom
vmoratti:Module-Data-Groups/Sprint1
Open

London | 26-ITP-May | Vito Moratti | Sprint 1 | Module data groups/sprint1#1297
vmoratti wants to merge 28 commits into
CodeYourFuture:mainfrom
vmoratti:Module-Data-Groups/Sprint1

Conversation

@vmoratti

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

Completed exercises for Sprint 1 except for stretch, which i didn't have time for.

Questions

Stretch is optional right?

@vmoratti vmoratti added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 26, 2026
Comment thread Sprint-1/fix/median.js Outdated
Comment on lines +21 to +23
if (!Array.isArray(list) || list.length < 2) {
return null;
}

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.

Why can't an array containing one number have a median?

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

Comment thread Sprint-1/implement/dedupe.js Outdated
Comment on lines +26 to +28
test("given an array with no duplicates, it returns a copy of the original array", () => {
expect(dedupe([1, 2, 3])).toEqual([1, 2, 3]);
});

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 implementation is correct. However, this test could be improved to better ensure
that any future changes continue to align with the expected behavior described on line 25:

Then it should return a copy of the original array

This test should fail if the function returns the original array (instead of a copy of the original array).

The current test checks only if both the original array and the returned array contain identical elements.
In order to validate the returned array is a different array, we need an additional check.

Can you find out what this additional check is?

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 have now added test to check if the returned array is a copy

Comment thread Sprint-1/implement/max.js Outdated
Comment thread Sprint-1/implement/max.test.js Outdated
Comment thread Sprint-1/implement/sum.js Outdated
@@ -1,4 +1,10 @@
function sum(elements) {
let innit = 0;

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.

What does the name innit mean?

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 have changed the variable name to "counter"

Comment thread Sprint-1/implement/sum.js Outdated
Comment thread Sprint-1/implement/sum.js Outdated
Comment on lines 7 to 8
return innit;
}

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.

Indentation is off.

Comment thread Sprint-1/implement/sum.test.js
Comment thread Sprint-1/refactor/includes.js Outdated
@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 Jul 31, 2026

@vmoratti vmoratti left a comment

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.

fixed median function

@vmoratti vmoratti added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 2, 2026

@cjyuan cjyuan left a comment

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.

Changes look good. I just have a few more suggestions.

Comment thread Sprint-1/fix/median.js
if (filteredList.length < 1) {
return null;
}
const sortedList = filteredList.sort((a, b) => a - b);

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.

Do explore the difference between .toSorted() and .sort().

Comment on lines +39 to +43
const original = [1, 2, 3];
const result = dedupe(original);

expect(result).toEqual([1, 2, 3]);
expect(result).not.toBe(original);

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.

This test is correct, but shouldn't it be defined at line 27?

Comment thread Sprint-1/implement/sum.js
@@ -1,4 +1,13 @@
function sum(elements) {
let counter = 0;

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.

Could also use total.

Comment thread Sprint-1/implement/sum.js
@@ -1,4 +1,13 @@
function sum(elements) {
let counter = 0;
const filteredList = elements.filter((value) => typeof value === "number" && !isNaN(value) && isFinite(value));

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.

Note: Number.isFinite() checks all three conditions.

@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 Aug 2, 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