Skip to content

Conversation

@SuWebOnes
Copy link

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@SuWebOnes SuWebOnes added 🔑 Priority Key Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 22, 2025
@a-robson a-robson 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 Jul 29, 2025
Copy link

@a-robson a-robson left a comment

Choose a reason for hiding this comment

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

Excellent. Code quality is high and you are making great progress. I've made some comments and suggestions.

Comment on lines +9 to +10
// Clone and sort the array numerically
const sorted = [...nums].sort((a, b) => a - b);

Choose a reason for hiding this comment

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

Overall this is excellent. But is it necessary to clone the array here? Could we just sort it?

Comment on lines +1 to +16
function dedupe(arr) {
if (!Array.isArray(arr)) return [];

const seen = new Set();
const result = [];

for (const item of arr) {
if (!seen.has(item)) {
seen.add(item);
result.push(item);
}
}

return result;
}

Choose a reason for hiding this comment

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

Very good. Using a Set is the right approach. However there are easier ways in Javascript to populate a Set from an array. Do we need a for loop at all?

Comment on lines 1 to 7
function sum(elements) {
if (!Array.isArray(elements)) return 0;

return elements.reduce((acc, val) => {
return typeof val === "number" && !isNaN(val) ? acc + val : acc;
}, 0);
}

Choose a reason for hiding this comment

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

Very good. However using filter() then reduce() is a more common approach to this type of problem. What are the advantages of using this pattern rather than having the 'filtering logic' within the reduce() function?

@a-robson a-robson 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 Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants