Repository navigation
Cape Town | 26-ITP-Sept | Leigh Ross | Sprint 2 | Coursework sprint 2 - #1503
Open
leigh-ross wants to merge 10 commits into
Open
leigh-ross wants to merge 10 commits into
leigh-ross wants to merge 10 commits into
Conversation
…mplemented tests. All tests pass
…ingle object with key value pairs (each array being a k-v pair). Implemented test. Test passes. Using Object method
…an object with key and value pairs, using guidance from already written test cases. All tests pass
…cy of each item then returns an object with each item-frequency pair. Implemented tests and all tests pass.
…d bracket notation to assign propeties which handles swopping key-value pairs. Added test file and tests. all tests pass
cjyuan
reviewed
Nov 16, 2026
cjyuan
left a comment
Contributor
There was a problem hiding this comment.
Could you use prettier to format the code in all files to keep the code consistently formatted?
Comment on lines
53
to
+62
| // Given a value that isn't an object - an array, a string, a number, | ||
| // null, or no argument at all | ||
| // When passed to contains | ||
| // Then it should throw Error("contains requires an object") | ||
| // (careful: typeof [] and typeof null are both "object") | ||
| test("given: value that is not an object throws error: 'contains requires an object'", () => { | ||
| const input = "tooth"; | ||
| const key = 'k' | ||
| expect(() => contains(input, key)).toThrow("contains requires an object") | ||
| }); No newline at end of file |
Contributor
There was a problem hiding this comment.
Could you also test arrays and other non-object values?
| for (const pair of keyValuePairs) { | ||
| const [key, value] = pair.split("="); | ||
| queryParams[key] = value; | ||
| let keyValuePair = keyValuePairs; |
Contributor
There was a problem hiding this comment.
The name keyValuePair does not clearly convey how the value stored in keyValuePair differs from the value stored in keyValuePairs.
Comment on lines
+8
to
+15
| if (queryString.includes("+")) { | ||
| keyValuePair = keyValuePairs.map((keyValuePair) => | ||
| keyValuePair.replaceAll("+", " ") | ||
| ); | ||
| } else if(queryString.includes("%")) { | ||
| keyValuePair = keyValuePairs.map((keyValuePair) => | ||
| decodeURIComponent(keyValuePair)) | ||
| }; |
Contributor
There was a problem hiding this comment.
-
A key or value could contain both
+and percent-encoded characters. They are not exclusive. -
If you decode the percent-encoded characters here, then the function would not correctly decode
a%3Db=x+yto{ 'a=b': 'x y' }.
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
Task code
CYF-1083
Changelist
Sprint 2 changes: