Repository navigation
London | 26-ITP-Sep | Mahir Shah | Sprint 2 | Sprint 2 coursework #1505
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
MahirShah300
wants to merge
19
commits into
CodeYourFuture:main
Choose a base branch
from
MahirShah300: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
19 commits
Select commit
Hold shift + click to select a range
f88a9ac
Fix bug by using .notation to access address houseNumber
MahirShah300 39abe5d
Fix bug by using Object.entries()
MahirShah300 3440f81
Fix printing of ingredients
MahirShah300 a486ddc
Implement tests for contains.js
MahirShah300 d472910
Implement contains() and a checkIfObj function
MahirShah300 00af950
Add test for createLookUp
MahirShah300 3c250b6
Implement createLookUp
MahirShah300 24b7c4a
Implement tests for tally
MahirShah300 cf0fc0f
Implement tally function
MahirShah300 5515ce1
Implement querystring function
MahirShah300 c13d79c
Answered questions and fixed invert function
MahirShah300 cfa87df
Add test to check invert
MahirShah300 5dc552e
Fix object check by removing prototype check and adding isArray check
MahirShah300 2eb8042
Fix formatting
MahirShah300 8c8c0de
Fix contains function by using hasOwn() instead of Object.keys().incl…
MahirShah300 7c5e2cc
Add tests for numeric keys
MahirShah300 1463eca
Used array destructuring syntax for better readability
MahirShah300 4a35b72
Fix implementation by replacing all + first, then decoding
MahirShah300 42e3422
Add test for percent encoded + character
MahirShah300 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,16 @@ | ||
| function contains() {} | ||
| function checkIfObj(objToCheck) { | ||
| if ( | ||
| typeof objToCheck !== "object" || | ||
| objToCheck === null || | ||
| Array.isArray(objToCheck) | ||
| ) { | ||
| throw new Error("contains requires an object"); | ||
| } | ||
| } | ||
|
|
||
| function contains(objToCheck, keyToSearch) { | ||
| checkIfObj(objToCheck); | ||
| return Object.hasOwn(objToCheck, keyToSearch); | ||
| } | ||
|
|
||
| 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(countryCurrencyPairs) { | ||
| const objCountryCurrencyPairs = {}; | ||
|
|
||
| for (const [country, currency] of countryCurrencyPairs) { | ||
| objCountryCurrencyPairs[country] = currency; | ||
| } | ||
|
|
||
| return objCountryCurrencyPairs; | ||
| } | ||
|
|
||
| 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,16 @@ | ||
| function tally() {} | ||
| function tally(itemList) { | ||
| if (!Array.isArray(itemList)) { | ||
| throw new Error("tally requires an array"); | ||
| } | ||
| const talliedItems = {}; | ||
| for (const item of itemList) { | ||
| if (!Object.keys(talliedItems).includes(item)) { | ||
| talliedItems[item] = 1; | ||
| } else { | ||
| talliedItems[item] += 1; | ||
| } | ||
| } | ||
| return talliedItems; | ||
| } | ||
|
|
||
| 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,5 @@ | ||
| const invert = require("./invert.js"); | ||
|
|
||
| test("Given object, returns object with inverted values and keys", () => { | ||
| expect(invert({ a: 8, b: 2 })).toEqual({ 8: "a", 2: "b" }); | ||
| }); |
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.
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.
Why not use a formatter to keep the code consistently formatted? (The spacing around the array elements is not consistent).
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.
Used prettier to format everything