generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 191
London | 25-ITP-Sep| Sophia Mohamed | Sprint 2 | Sprint 2 Coursework #861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
saff-coder
wants to merge
16
commits into
CodeYourFuture:main
Choose a base branch
from
saff-coder:Sprint-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3999300
corrected te Address function
saff-coder 8163ad3
fixed the error in the code
saff-coder 65b3e2d
corrected the function in recipe
saff-coder 53492c8
Update the function and run the tests
saff-coder b8ae2b9
implement a function and run the tests
saff-coder 6cf8277
Implementation and tests done on Querystring
saff-coder 0d76de5
implementing the function tally and all the tests are done
saff-coder c64fdeb
the function was updated and the error explained
saff-coder 2b867f0
updated the function and the test
saff-coder 9411e67
updated the function and the test in querysting.js
saff-coder 3be182c
updated the code
saff-coder ee8befa
updated the recipe function
saff-coder 96fc157
updated the contain.test
saff-coder 604d8ff
updated the lookup function
saff-coder 0e9c2c9
Updated both querystring and querystring.test
saff-coder e3eee4c
updated the test and the code in tally function
saff-coder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| function contains() {} | ||
| function contains(obj, key) { | ||
| if (obj === null || typeof obj !== "object") return false; | ||
|
|
||
| return Object.prototype.hasOwnProperty.call(obj, key);// Updated to use hasOwnProperty to check for own properties only | ||
| } | ||
|
|
||
| module.exports = contains; |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| function createLookup() { | ||
| // implementation here | ||
| function createLookup(pairs) { | ||
| const lookup = {}; | ||
|
|
||
| for (const [country, currency] of pairs) { | ||
| lookup[country] = currency; | ||
| } | ||
|
|
||
| return lookup; | ||
| } | ||
|
|
||
| module.exports = createLookup; |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,22 @@ | ||
| function parseQueryString(queryString) { | ||
| const queryParams = {}; | ||
| if (queryString.length === 0) { | ||
| return queryParams; | ||
| function parseQueryString(query) { | ||
| const result = {}; | ||
|
|
||
| if (!query) { | ||
| return result; | ||
| } | ||
| const keyValuePairs = queryString.split("&"); | ||
|
|
||
| for (const pair of keyValuePairs) { | ||
| const [key, value] = pair.split("="); | ||
| queryParams[key] = value; | ||
| // URLSearchParams treats "+" as space (" "). | ||
| // Our tests expect "+" to stay as "+" (e.g. "x=y+1"), | ||
| // so we temporarily encode "+" as "%2B" before parsing. | ||
| const safeQuery = query.replace(/\+/g, "%2B"); | ||
|
|
||
| const params = new URLSearchParams(safeQuery); | ||
|
|
||
| for (const [key, value] of params) { | ||
| result[key] = value; | ||
| } | ||
|
|
||
| return queryParams; | ||
| return result; | ||
| } | ||
|
|
||
| module.exports = parseQueryString; |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,16 @@ | ||
| function tally() {} | ||
| function tally(arr) { | ||
| if (!Array.isArray(arr)) { | ||
| throw new TypeError("Input must be an array"); | ||
| } | ||
|
|
||
| // Use an object with no prototype to avoid collisions with keys like "constructor" | ||
| const counts = Object.create(null); | ||
|
|
||
| for (const item of arr) { | ||
| counts[item] = (counts[item] || 0) + 1; | ||
| } | ||
|
|
||
| return counts; | ||
| } | ||
|
|
||
| module.exports = tally; |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
tally(["constructor", "constructor"])return what you expect?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!
tally(["constructor", "constructor"]) didn’t work properly because I was using a normal {} object, so "constructor" clashed with the built-in constructor property.
I used Object.create(null) so "constructor" behaves like normal keys and doesn’t clash with JavaScript’s internal properties.