-
-
Notifications
You must be signed in to change notification settings - Fork 327
London | 26-ITP-May | Damilola Odumosu | Sprint 2 | Coursework #1352
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
d-odumosu
wants to merge
20
commits into
CodeYourFuture:main
Choose a base branch
from
d-odumosu:coursework/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
20 commits
Select commit
Hold shift + click to select a range
21ac6a2
The code now logs the correct address
d-odumosu 31437ab
refactored to use a for..in loop
d-odumosu 132dcb4
debugged and fixed the recipe file.
d-odumosu bfed0ed
completed all requirements for invert and written tests to pass.
d-odumosu 16db858
completed all requirements for contains and written tests to pass.
d-odumosu d7c4016
completed all requirements for lookup and written tests to pass.
d-odumosu ec2b1d0
completed all requirements of tally
d-odumosu 928a880
completed all requirements of invert
d-odumosu 330582e
completed all requirements of queryString
d-odumosu c5fcec5
refactored
d-odumosu 33087cd
refactored contains and contains.test
d-odumosu 7280413
refactored contains to use object.hasown
d-odumosu 6f021ec
added additional test to cover a non empty array
d-odumosu f576655
used object.create instead of the empty object
d-odumosu 6624821
fixed the bug returning empty strings
d-odumosu 80ebffb
completed changes on querystrings
d-odumosu cf78d67
changed the variable name from value to key
d-odumosu 9d3cc7d
included test for undefined
d-odumosu 740c965
removed number suffix from variable names
d-odumosu 1249b72
made changes to the double negative in the if statement
d-odumosu 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, property) { | ||
| if (typeof object !== "object" || Array.isArray(object) || object === null) { | ||
| throw new Error("Invalid data type"); | ||
| } | ||
| return Object.hasOwn(object, property); | ||
| } | ||
| 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,28 @@ | ||
| function createLookup() { | ||
| // implementation here | ||
| } | ||
| function createLookup(arr) { | ||
| if (!Array.isArray(arr)) { | ||
| throw new Error("invalid data type entered"); | ||
| } | ||
| if (arr.length === 0) { | ||
| throw new Error("country and currency code not entered"); | ||
| } | ||
|
|
||
| const objectLookup = {}; | ||
|
|
||
| for (const pair of arr) { | ||
| if (!Array.isArray(pair)) { | ||
| throw new Error("Each item must be an array."); | ||
| } | ||
| if (pair.length !== 2) { | ||
| throw new Error( | ||
| "Each inner array must contain exactly two elements: a key and a value" | ||
| ); | ||
| } | ||
| const [country, currency] = pair; | ||
| if (country === currency) { | ||
| throw new Error("Country code and currency code cannot be the same"); | ||
| } | ||
| objectLookup[country] = currency; | ||
| } | ||
| return objectLookup; | ||
| } | ||
| 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,13 @@ | ||
| function tally() {} | ||
|
|
||
| function tally(arr) { | ||
| if (!Array.isArray(arr)) { | ||
| throw new Error('Invalid data type entered"'); | ||
| } | ||
| if (arr.length === 0) { | ||
| return {}; | ||
| } | ||
| return arr.reduce((acc, cur) => { | ||
| acc[cur] = (acc[cur] || 0) + 1; | ||
| return acc; | ||
| }, Object.create(null)); | ||
| } | ||
| 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.
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.
.replaceAll()without the if statement.