Skip to content

Sheffield | 26-Jan-ITP | Martha Ogunbiyi| Sprint 1 | Coursework/sprint 1#1054

Open
marthak1 wants to merge 12 commits intoCodeYourFuture:mainfrom
marthak1:coursework/sprint-1
Open

Sheffield | 26-Jan-ITP | Martha Ogunbiyi| Sprint 1 | Coursework/sprint 1#1054
marthak1 wants to merge 12 commits intoCodeYourFuture:mainfrom
marthak1:coursework/sprint-1

Conversation

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

implemented sprint 1 course work

@marthak1 marthak1 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 20, 2026
Comment on lines 61 to +77
// Given an array with non-number values
// When passed to the max function
// Then it should return the max and ignore non-numeric values
test("given an array with non-number value, it should return the max and ignore non-numeric value", () => {
const input = [4, 5, 'arr', 2, []," ", 15, 8];
const result = findMax(input);
expect(result).toBe(15);
});

// Given an array with only non-number values
// When passed to the max function
// Then it should return the least surprising value given how it behaves for all other inputs
test("given an array with only non-number value, it should return the least surprising value given how it behaves for all other inputs", () => {
const input = [true, {}, "arr", null, [], " ", NaN];
const result = findMax(input);
expect(result).toBe(-Infinity);
}); No newline at end of file
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.

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.

Thanks for the feedback. I have refactored the implementation to not only check the 'type' , but to also check whether it can become a valid number

@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 20, 2026
@marthak1 marthak1 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 29, 2026
@cjyuan
Copy link
Copy Markdown
Contributor

cjyuan commented Mar 30, 2026

Changes look good. Well done.

@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. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 30, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants