Skip to content

Conversation

TzeMingHo
Copy link

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

I have created a function for finding the median, both tests and functions in the implement exercise, refactored the loop function, and found out the frequency of time travel.

@TzeMingHo TzeMingHo added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 1 Assigned during Sprint 1 of this module labels Oct 10, 2025
Copy link

@CameronDowner CameronDowner left a comment

Choose a reason for hiding this comment

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

Looking really good - I've left some more challenging question

I will mark as complete & this is done - but if you can answer these I think it will be a good challenge 🙂

}

// return [] if arr is []
if (arr.length === 0) return [];

Choose a reason for hiding this comment

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

Do we need a special case here?

// return [] if arr is []
if (arr.length === 0) return [];

return [...new Set(arr)];

Choose a reason for hiding this comment

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

What's special about Set that solves our problem here?

test("given an array with no duplicates, it returns the original array", () => {
expect(dedupe(["a", "b", "c"])).toEqual(["a", "b", "c"]);
expect(dedupe([1, 2, 3])).toEqual([1, 2, 3]);
expect(dedupe([{ key1: "a" }, { key2: "b" }, { key3: "c" }])).toEqual([

Choose a reason for hiding this comment

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

challenge: what would you expect if I did this?

dedupe([{ key1: "a" }, { key1: "a" }, { key1: "a" }])

return 0;
}

return elements.reduce((acc, num) => acc + num, 0);

Choose a reason for hiding this comment

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

Could you explain what this reduce function is doing?

@CameronDowner CameronDowner 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 Oct 18, 2025
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