Skip to content

London | 26-ITP-Sep | Shirin Panahian | Sprint 1 | Complete sprint 1 exercises - #1498

Open
shirinpanahian wants to merge 15 commits into
CodeYourFuture:mainfrom
shirinpanahian:Sprint-1
Open

shirinpanahian wants to merge 15 commits into
CodeYourFuture:mainfrom
shirinpanahian:Sprint-1

Conversation

@shirinpanahian

@shirinpanahian shirinpanahian commented Nov 6, 2026 •

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

Task code

CYF-1071

Changelist

Changelist

  • Implemented dedupe: Removes duplicate elements from an array while preserving the original order and first occurrence of each element. Handles empty arrays and arrays without duplicates.

  • Implemented findMax: Finds and returns the largest number in an array, with handling for empty arrays, single-element arrays and invalid inputs.

  • Implemented sum and mean: Added the functions to calculate the sum and arithmetic mean of an array of numbers.

  • Implemented calculateMedian: Calculates the median of an array of numbers, supporting both odd and even numbers of elements. Includes input validation and error handling.

  • Implemented describeMedian: Returns a descriptive message containing the calculated median, or an appropriate error message when the median cannot be calculated.

  • Refactored includes: Updated the implementation to use a for...of loop.

  • Added and updated tests: Expanded test coverage for normal cases, empty arrays, single-element arrays, duplicate elements and invalid inputs.

@github-actions

This comment has been minimized.

@shirinpanahian shirinpanahian 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. labels Nov 6, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 6, 2026
@github-actions

This comment has been minimized.

@shirinpanahian shirinpanahian added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 6, 2026
@cjyuan cjyuan added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 6, 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.

  • Function implementations are all correct. Well done.

  • Regarding the PR description, could you use AI to research what should be included in the "Changelist" section of a PR, then revise your Changelist content accordingly?

Comment thread Sprint-1/fix/median.js Resolved
Comment thread Sprint-1/fix/median.js
Comment on lines +24 to +26
const copy = [...list];
const middleIndex = Math.floor(listLength / 2);
copy.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.

Could also use Array.prototype.toSorted().

Comment thread Sprint-1/implement/dedupe.js Resolved
Comment thread Sprint-1/implement/dedupe.test.js Resolved
Comment thread Sprint-1/implement/max.test.js Resolved
Comment thread Sprint-1/implement/max.js Resolved
Comment thread Sprint-1/implement/max.test.js Resolved
Comment thread Sprint-1/implement/mean.test.js Resolved
Comment thread Sprint-1/implement/mean.js Resolved
Comment thread Sprint-1/implement/mean.test.js Resolved
@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Nov 6, 2026
@shirinpanahian shirinpanahian 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 Nov 6, 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 think one of the functions may not pass the tests you prepared.

Comment thread Sprint-1/implement/dedupe.js Outdated
Comment on lines +7 to +10
if (newList.includes(item)) {
continue;
}
newList.push(item);

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: Could also write

  if (!newList.includes(item)) {
     newlist.push(item);
  }

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.

thank you , that was good idea👍

Comment on lines +19 to +22
describe("findMax", () => {
it("given an empty array,returns -Infinity", () => {
expect(findMax([])).toEqual(-Infinity);
});

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.

Did you ran the test script after you made the changes?

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.

The issue is fixed, and the tests are now passing.

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 7, 2026
@cjyuan cjyuan added the Reviewed Volunteer to add when completing a review with trainee action still to take. label Nov 7, 2026
@shirinpanahian shirinpanahian 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 Nov 7, 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. Well done.

Comment thread Sprint-1/implement/max.js
Comment on lines +13 to +21
if (arrLength === 0) {
return -Infinity;
}

for (const item of elements) {
if (maxNum < item) {
maxNum = item;
}
}

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: The code on lines 12, 17-21 also works for empty array.

@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 Nov 8, 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. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants