Sheffield | 26-ITP-Jan | Mahammad Osman | Sprint 2 | Data Groups#1131
Open
Darkidd77 wants to merge 9 commits intoCodeYourFuture:mainfrom
Open
Sheffield | 26-ITP-Jan | Mahammad Osman | Sprint 2 | Data Groups#1131Darkidd77 wants to merge 9 commits intoCodeYourFuture:mainfrom
Darkidd77 wants to merge 9 commits intoCodeYourFuture:mainfrom
Conversation
…ments for clarity
…ry-currency pairs
…s; implement tally function with error handling and corresponding tests
…omprehensive tests for various cases in invert.test.js. Create countWords function to count word occurrences in a string; add corresponding tests in count-words.test.js.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…ing me to commit ann make my pr
cjyuan
reviewed
Apr 2, 2026
…s; add corresponding tests for these cases
…st for handling prototype keywords correctly
cjyuan
reviewed
Apr 6, 2026
Comment on lines
+1
to
+6
| function contains(obj, prop) { | ||
| if (Array.isArray(obj) || obj === undefined || obj === null) { | ||
| return false; | ||
| } | ||
| return obj.hasOwnProperty(prop); | ||
| } |
Contributor
There was a problem hiding this comment.
Can you check if contains("abc", "0") returns what you expect?
Author
There was a problem hiding this comment.
hmmm indeed it doesn't? So after Looking into it I realised that JS considers not only arrays to be objects, but strings are actually arrays in disguise too, so the string "abc" behind the scene is actually:
{ "0": "a", "1": "b", "2": "c", "length": 3 }
meaning "abc".hasOwnProperty("0") evaluates to true
I've updated the guard clauses to include typeof obj !== 'object' to immediately filter out strings, numbers, and booleans. Thanks
…ing input handling
Contributor
|
All good now. Well done. |
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:
Completed the tasks per instructions.