Repository navigation
London | 26-ITP-Sep | Mars Adesina | Sprint 2 | Module-Data-Groups #1530
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
marscancode
wants to merge
32
commits into
CodeYourFuture:main
Choose a base branch
from
marscancode:coursework/data-groups-sprint-2-clean
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.
+146
−42
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
5d54c31
fix house number access in address object
marscancode 8d0e38a
fixed loop to print author object values
marscancode 1f4ed4b
fixed recipe and loop output
marscancode 7faefe4
Add empty object test for contains
marscancode 0c0415d
implemented check for empty object in contains
marscancode e0d3618
added test to check wether object contains property
marscancode cd8545b
implemented property check in contains
marscancode 92710cd
added missing property test for contains
marscancode 123e142
added test to check wether contains throws an error for arrays
marscancode a770518
implemented contains to handle arrays
marscancode 1c0e82d
added test to check contains throws an error for strings
marscancode 6a55470
implemented contains to handle strings
marscancode 6befbcd
added test to check wether contains throws an error when given a number
marscancode e9bc9c6
implemented contains to handle numbers
marscancode 4866df9
test to check wether contains throws an error for null
marscancode 9e57410
implemented contains to handle null
marscancode 8d4c1cc
added to test to check wether contains throws an error with no argum…
marscancode ab6963f
implemented contains to handle undefined
marscancode 7e908fb
added test for lookup with multiple currency pairs
marscancode aadb7e6
update
marscancode aeef626
Implemented country currency lookup
marscancode c362f4e
test to check lookup returns an empty object when given an empty array
marscancode f50f02a
added test to check that lookup handles duplicate country codes
marscancode 9731b4d
Removed optional stretch test for duplicate keys
marscancode f7ffc4d
Fixed query string handling for edge cases
marscancode 7a823ce
added test for tally with an empty array
marscancode 21d9972
Test to check if tally counts items in an array
marscancode 590c736
Test to check if tally rejects invalid inputs
marscancode a5f091f
invert exercise answers
marscancode 13a4171
implemented invert to swap object keys and values
marscancode f1cbb62
Tests to check invert handles multiple key-value pairs
marscancode ca51a9f
test to check if invert handles empty objects
marscancode 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,23 @@ | ||
| function contains() {} | ||
| function contains(obj, propertyName) { | ||
| if (Array.isArray(obj)) { | ||
| throw new Error("contains requires an object"); | ||
| } | ||
| if (typeof obj === "string") { | ||
| throw new Error("contains requires an object"); | ||
| } | ||
| if (typeof obj === "number") { | ||
| throw new Error("contains requires an object"); | ||
| } | ||
| if (obj === null) { | ||
| throw new Error("contains requires an object"); | ||
| } | ||
| if (obj === undefined) { | ||
| throw new Error("contains requires an object"); | ||
| } | ||
| if (Object.keys(obj).length === 0) { | ||
| return false; | ||
| } | ||
|
|
||
| return Object.keys(obj).includes(propertyName); | ||
| } | ||
| 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,9 @@ | ||
| function createLookup() { | ||
| // implementation here | ||
| function createLookup(countryCurrencyPairs) { | ||
| const lookup = {}; | ||
| for (const pair of countryCurrencyPairs) { | ||
| lookup[pair[0]] = pair[1]; | ||
| } | ||
| 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
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,20 @@ | ||
| function tally() {} | ||
| function tally(items) { | ||
| const counts = {}; | ||
| if (!Array.isArray(items)) { | ||
| throw new Error("tally requires an array"); | ||
| } | ||
|
|
||
| for (let i = 0; i < items.length; i++) { | ||
| const item = items[i]; | ||
|
|
||
| if (Object.keys(counts).includes(item)) { | ||
| counts[item] = counts[item] + 1; | ||
| } else { | ||
| counts[item] = 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
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| const invert = require("./invert.js"); | ||
|
|
||
| test("given a key-value pair, should return it inverted", () => { | ||
| expect(invert({ a: 1 })).toEqual({ 1: "a" }); | ||
| }); | ||
|
|
||
| test("given multiple key-value pairs, should return them inverted", () => { | ||
| expect(invert({ a: 1, b: 2 })).toEqual({ 1: "a", 2: "b" }); | ||
| }); | ||
|
|
||
| test("given an empty object, should return an empty object", () => { | ||
| expect(invert({})).toEqual({}); | ||
| }); |
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.
What does
contains(false, "a")do with these type checks, given the requirement that non-object inputs throw?To "like" or "dislike" this comment, please follow this link