London | 26-ITP-Jan | Carlos Abreu |Sprint 1 | Data Module Groups#1105
Open
carlosyabreu wants to merge 7 commits intoCodeYourFuture:mainfrom
Open
London | 26-ITP-Jan | Carlos Abreu |Sprint 1 | Data Module Groups#1105carlosyabreu wants to merge 7 commits intoCodeYourFuture:mainfrom
carlosyabreu wants to merge 7 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
reviewed
Mar 26, 2026
Comment on lines
+22
to
+23
| // Sort the numbers in ascending order | ||
| const sorted = [...numbers].sort((a, b) => a - b); |
Contributor
There was a problem hiding this comment.
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'); | ||
|
|
Contributor
There was a problem hiding this comment.
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); | ||
| }); |
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Changelist
PR for Sprint 1 of Data Module Group Coursework