Repository navigation
London | 26-ITP-Sep | Shirin Panahian | Sprint 2| Complete sprint 2 exercises - #1516
shirinpanahian wants to merge 8 commits into
Conversation
|
Thank you for this PR. Great work completing the Sprint 2 exercises and adding tests. I can see two small JavaScript edge cases to fix before merging: tally.js (line 12): Plain objects inherit built-in keys like toString, so tally(["toString"]) tries to add 1 to a function instead of returning { toString: 1 }. Using Object.hasOwn() or Object.create(null) fixes this. querystring.js (line 38): Assigning "proto" directly to a normal object changes its prototype instead of saving it as a key. Using Object.create(null) or Object.defineProperty() handles it safely. |
|
Thank you for the feedback and the helpful explanations! I've fixed both edge cases using I've also added tests to cover these cases and pushed the updates to the PR. Thanks again for the review!
|
| if (Object.hasOwn(tallyObj, item)) { | ||
| tallyObj[item] = tallyObj[item] + 1; | ||
| } else { | ||
| tallyObj[item] = 1; |
There was a problem hiding this comment.
What own property does the {} accumulator get when an input item is "__proto__"? Try tally(["__proto__"]) and compare the result with the requirement to count every item.
To "like" or "dislike" this comment, please follow this link
| console.log( | ||
| createLookup([ | ||
| ["US", "USD"], | ||
| ["CA", "CAD"], | ||
| ]) | ||
| ); |
There was a problem hiding this comment.
What appears in the test process output when lookup.test.js requires this module?
To "like" or "dislike" this comment, please follow this link
| test("given an object, returns true as the object contains a key of 'a'", function () { | ||
| const input = contains({ a: 1, b: 2 }, "c"); | ||
| const currentOutput = input; | ||
| const targetOutput = false; |
There was a problem hiding this comment.
How do the descriptions for the "c", numeric, null, and missing-argument cases compare with their inputs and assertions?
To "like" or "dislike" this comment, please follow this link
| console.log(author[value]); | ||
| } | ||
| //author is Object and it is not iterable | ||
| //for...of loop excepts array and string but it not working with object type |
There was a problem hiding this comment.
Besides arrays and strings, what other iterable types can a for...of loop handle?
To "like" or "dislike" this comment, please follow this link
|
The CYF AI review has left comments. It will only review a PR one time. When you have addressed these comments, please request review again and a volunteer will take a look. |
Learners, PR Template
Self checklist
Task code
CYF-1083
Changelist
This PR includes my work for Sprint 2 of the Module Data Groups project.
contains,lookup,tally, andquerystring. Tested the functions with different inputs to verify their behaviour.console.log().This sprint helped me improve my JavaScript problem-solving, debugging, implementation, and code-reading skills.