-
-
Notifications
You must be signed in to change notification settings - Fork 320
London | 26-ITP-JAN | Asha Ahmed | Sprint 2 | Data Groups #1127
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
Closed
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
534a974
Fix: correct access to houseNumber property in address object
ashaahmed7 0d798f0
Fix: correct iteration method for logging author properties
ashaahmed7 5670003
Fix: recipe to be logged as a string
ashaahmed7 25e3754
add utility to check if object contains a key
ashaahmed7 0667ae6
added unit tests for contains()
ashaahmed7 0300033
Implement createLookup to map country-currency pairs into an object
ashaahmed7 8a041eb
Add tests for createLookup covering invalid input, empty array, and v…
ashaahmed7 3efccb1
Improved parseQueryString to support URL decoding, keys without value…
ashaahmed7 2b8e742
Added parseQueryString tests for duplicate keys, encoded values, miss…
ashaahmed7 458dd94
Added tally function to count occurrences of items in an array
ashaahmed7 47d6c64
Added tally tests for empty array, item counting, and invalid input.
ashaahmed7 31506e5
fixed: implement correct key-value inversion and add tests for invert…
ashaahmed7 5cdbb30
Merge branch 'main' into sprint-2
ashaahmed7 be1e465
Fixed recipe logging format to display ingredients on separate lines
ashaahmed7 c1f9f2b
Refactor contains function to improve type checking and simplify logi…
ashaahmed7 2a82a4d
Merge branch 'sprint-2' of https://github.com/ashaahmed7/Module-Data-…
ashaahmed7 6bcdc70
refactor: improve input validation in tally function
ashaahmed7 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
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,11 @@ | ||
| function contains() {} | ||
| function contains(object, name) { | ||
| // Return false for null, undefined, primitives, and arrays | ||
| if (object == null || typeof object !== "object" || Array.isArray(object)) { | ||
| return false; | ||
| } | ||
|
|
||
| // Now safe to use Object.hasOwn | ||
| return Object.hasOwn(object, name); | ||
| } | ||
|
|
||
| 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,13 @@ | ||
| function createLookup() { | ||
| // implementation here | ||
| const array = {}; | ||
|
|
||
| for (const pair of countryCurrencyPairs) { | ||
| const country = pair[0]; | ||
| const currency = pair[1]; | ||
| array[country] = currency; | ||
| } | ||
|
|
||
| return array; | ||
| } | ||
|
|
||
| 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
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,22 @@ | ||
| function tally() {} | ||
| function tally(itemsList) { | ||
| // Guard against invalid inputs | ||
| if (!Array.isArray(itemsList)) { | ||
| if (itemsList == null) return {}; | ||
| throw new Error("Input must be an array"); | ||
| } | ||
|
|
||
| if (itemsList.length === 0) { | ||
| return {}; | ||
| } | ||
|
|
||
| // Create object with no prototype to avoid "toString" collision issues | ||
| const counts = Object.create(null); | ||
|
|
||
| for (const item of itemsList) { | ||
| 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.
Uh oh!
There was an error while loading. Please reload this page.