Skip to content

London | 26-ITP-Jan | Carlos Abreu |Sprint 1 | Data Module Groups#1105

Open
carlosyabreu wants to merge 7 commits intoCodeYourFuture:mainfrom
carlosyabreu:coursework/sprint-1
Open

London | 26-ITP-Jan | Carlos Abreu |Sprint 1 | Data Module Groups#1105
carlosyabreu wants to merge 7 commits intoCodeYourFuture:mainfrom
carlosyabreu:coursework/sprint-1

Conversation

@carlosyabreu
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

PR for Sprint 1 of Data Module Group Coursework

@carlosyabreu carlosyabreu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 26, 2026
Comment on lines +22 to +23
// Sort the numbers in ascending order
const sorted = [...numbers].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.

Is it necessary to make a copy of numbers before sorting?

Comment on lines +3 to +5
// Filter out non-numeric values
const numbers = elements.filter(element => typeof element === 'number');

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 do you expect from the following function calls (on extreme cases)?
Does your function return the value you expected?

findMax([NaN])
findMax([0, NaN, 1])

Comment on lines +49 to +53
test("given an array with non-number values, returns the max and ignores non-numeric values", () => {
expect(findMax(['hey', 10, 'hi', 60, 10])).toBe(60);
expect(findMax([20, 'abc', 30, 'def', 40])).toBe(40);
expect(findMax(['x', 'y', 'z', 100, 50])).toBe(100);
});
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.

When a string representing a valid numeric literal (for example, "300") is compared to a number,
JavaScript first converts the string into its numeric equivalent before performing the comparison.
As a result, the expression 20 < "300" evaluates to true.

To test if the function can correctly ignore non-numeric values,
consider including a string such as "300" in the relevant test cases.

@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 Mar 26, 2026
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.

2 participants