-
-
Notifications
You must be signed in to change notification settings - Fork 327
London | 26-ITP-May | Liridona Shehu | Sprint 2 | Module Data Groups #1284
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
shehu-dona
wants to merge
18
commits into
CodeYourFuture:main
Choose a base branch
from
shehu-dona: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
18 commits
Select commit
Hold shift + click to select a range
4b7a603
Fixed address function
dona-shehu 1b6c8af
Fixed author ()
dona-shehu 62eb30b
Fixed recipe ingredients
dona-shehu b770df8
Implemented contains()
dona-shehu d3ad67e
Added tests for contains ()
dona-shehu 9c6a37b
Implemented createLookup()
dona-shehu 917a7a1
Add tests for createLookup()
dona-shehu f029ada
Implemented parseQueryString()
dona-shehu 7d913ac
Added tests for parseQueryString()
dona-shehu a0bf22b
Implemented tally()
dona-shehu 16e0368
Added tests for tally()
dona-shehu 67163fd
implemented invert()
dona-shehu 32248d6
Added tests for invert()
dona-shehu 25179d2
Added if condition for undefined and null
dona-shehu 1542cb5
Added test for undefine and null values
dona-shehu e397f38
Added if condition for null and undefined
dona-shehu 4dde84f
Add test case for null and undefined
dona-shehu 1463f5d
Removed duplicate test case
dona-shehu 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(object, propertyName) { | ||
| if (Object.hasOwn(object, propertyName)) { | ||
| return true; | ||
| } else return false; | ||
| } | ||
|
|
||
| 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,10 @@ | ||
| function createLookup() { | ||
| function createLookup(data) { | ||
| // implementation here | ||
| const newObject = {}; | ||
| for (const [country, currency] of data) { | ||
| newObject[country] = currency; | ||
| } | ||
| return newObject; | ||
| } | ||
|
|
||
| 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,15 @@ | ||
| function tally() {} | ||
| function tally(items) { | ||
| if (!Array.isArray(items)) { | ||
| throw new Error("Invalid input"); | ||
| } | ||
| const itemsObj = {}; | ||
| for (const item of items) { | ||
| if (item === undefined || item === null) continue; | ||
| if (itemsObj[item] === undefined) { | ||
| itemsObj[item] = 1; | ||
| } else itemsObj[item]++; | ||
| } | ||
| return itemsObj; | ||
| } | ||
|
|
||
| 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,24 @@ | ||
| const invert = require("./invert.js"); | ||
|
|
||
| // Given an empty object | ||
| // When invert is passed this object | ||
| // Then it should return an empty object. | ||
| test("Given an empty object,should return an empty object", () => { | ||
| expect(invert({})).toEqual({}); | ||
| }); | ||
|
|
||
| // Given an object | ||
| // When invert is passed this object | ||
| // Then it should swap the keys and values in the object | ||
| test("Given an object, should swap the keys and values in the object", () => { | ||
| expect(invert({ a: 1 })).toEqual({ 1: "a" }); | ||
| expect(invert({ a: 1, b: 2 })).toEqual({ 1: "a", 2: "b" }); | ||
| expect(invert({ a: 1, b: 2, c: 3, d: 4 })).toEqual({ | ||
| 1: "a", | ||
| 2: "b", | ||
| 3: "c", | ||
| 4: "d", | ||
| }); | ||
| }); | ||
|
|
||
| test("Given an empty object, should swap the keys and values in the object", () => {}); |
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 will happen if I pass the following input to the fn?
["apple", "banana", "apple", "orange", "banana", undefined]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.
It treated undefined as a key and we receive undefined:1. Added if condition to ignore undefined and null