London | 26-ITP-May | Russom Gebremeskel | Sprint 2 | Coursework - #1351
Open
russom-g wants to merge 36 commits into
Open
London | 26-ITP-May | Russom Gebremeskel | Sprint 2 | Coursework#1351russom-g wants to merge 36 commits into
russom-g wants to merge 36 commits into
Conversation
added 26 commits
July 16, 2026 20:57
… from the key and value.
…irst and catch the error.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cjyuan
reviewed
Aug 5, 2026
| @@ -1,3 +1,10 @@ | |||
| function contains() {} | |||
| function contains(object, property) { | |||
| for (let key in object) { | |||
Contributor
There was a problem hiding this comment.
Normally, when we use for...in or for...of loops, we don't need to modify the loop variable within the loop. As a result, a common practice is to declare the loop variable using const.
Comment on lines
47
to
+52
| // Given invalid parameters like an array | ||
| // When passed to contains | ||
| // Then it should return false or throw an error | ||
| test("contain on invalid parameters returns false", function () { | ||
| expect(contains([], "0")).toBe(false); | ||
| }); |
Contributor
There was a problem hiding this comment.
Could you check if contains(['a', 'b', 'c'], "0") return the value you expect?
| if (!Array.isArray(arr)) { | ||
| throw new Error("Invalid input"); | ||
| } | ||
| const count = {}; |
Contributor
There was a problem hiding this comment.
Does the following function call returns the value you expect?
tally(["toString", "toString"]);
Suggestion:
- Look up an approach to create an empty object with no inherited properties, or
- use
Object.hasOwn()
added 7 commits
August 6, 2026 16:01
…ue instead of position
cjyuan
reviewed
Aug 12, 2026
Comment on lines
+14
to
16
| for (const value in author) { | ||
| console.log(author[value]); | ||
| } |
Contributor
There was a problem hiding this comment.
The loop variable value takes on the key (or property) of the object. Naming it 'value' could confuse people.
Comment on lines
+1
to
+8
| function contains(object, property) { | ||
| for (const key in object) { | ||
| if (object[key] === property) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } |
Contributor
There was a problem hiding this comment.
Could this function pass all the tests in contains.test.js?
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.
An implementation fixed. A test created to prove the function works as required.