London | 26-ITP-May | Vito Moratti | Sprint 2 | Coursework - #1364
Open
vmoratti wants to merge 17 commits into
Open
London | 26-ITP-May | Vito Moratti | Sprint 2 | Coursework#1364vmoratti wants to merge 17 commits into
vmoratti wants to merge 17 commits into
Conversation
cjyuan
reviewed
Aug 8, 2026
Add check for arrays in contains function
cjyuan
reviewed
Aug 9, 2026
Comment on lines
42
to
47
| // Given invalid parameters like an array | ||
| // When passed to contains | ||
| // Then it should return false or throw an error | ||
| test("contains an object returns true, or false otherwise", () => { | ||
| expect(contains([1, 2, 3, 'a'], "a")).toBe(false); | ||
| expect(contains([1, 2, 3, 'a'], "0")).toBe(false); | ||
| }); |
Contributor
There was a problem hiding this comment.
Invalid parameters also include values like null, undefined, 1234, true. Could your function also return false when the first argument is one of these values?
Author
There was a problem hiding this comment.
I have added extra validation to the contains() function now.
I believe it was not in the instruction, nor in the tests, that's why i didn't add them initially.
Refactor contains function to handle null, undefined, and Number types.
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.
Self checklist
Changelist
I attempted all tasks except the stretch