-
-
Notifications
You must be signed in to change notification settings - Fork 324
London | 26-ITP-May | Chun Yan Wong | Sprint 2 | Coursework #1367
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
cywong-dev
wants to merge
20
commits into
CodeYourFuture:main
Choose a base branch
from
cywong-dev: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
5a797a0
Fix iteration method for author object
cywong-dev 013e56d
Update address.js
cywong-dev 5e4611f
Display recipe ingredients in the console
cywong-dev e720a7c
Enhance contains function with input validation
cywong-dev b7442ae
Implement tests for contains function
cywong-dev d2af991
Add createLookup function in lookup.js
cywong-dev 3af6a3b
Implement test for country currency code lookup
cywong-dev c9a22bb
Refactor parseQueryString for better handling
cywong-dev 78a88c6
Add tests for duplicate keys in query string parsing
cywong-dev 2d7c3ad
Implement tally function with input validation
cywong-dev 720be29
Update tally.test.js
cywong-dev e6ff252
Add test cases for existing property names in contains
cywong-dev 427c69c
Correct implementation of invert function
cywong-dev 978200e
Enhance countWords function with input checks
cywong-dev 3dfb2a8
Refactor calculateMode into smaller functions
cywong-dev f204ada
Fix totalTill implementation and add test case
cywong-dev ac40924
Replace hasOwnProperty with Object.hasOwn
cywong-dev 514a218
Update error message in tally test for invalid input
cywong-dev df05b38
Refactor tally function to use Object.hasOwn
cywong-dev f2c4d62
Modify createLookup to accept parameters
cywong-dev 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,13 @@ | ||
| function contains() {} | ||
| function contains() { | ||
|
|
||
| // Return false if obj is null, undefined, an array, or not a non-null object | ||
| if (typeof obj !== "object" || obj === null || Array.isArray(obj)) { | ||
| return false; | ||
| } | ||
|
|
||
| // Check if the property exists directly on the object | ||
| return Object.hasOwn(obj, prop); | ||
|
|
||
| } | ||
|
|
||
| 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
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,35 +1,20 @@ | ||
| const createLookup = require("./lookup.js"); | ||
|
|
||
| test.todo("creates a country currency code lookup for multiple codes"); | ||
|
|
||
| /* | ||
|
|
||
| Create a lookup object of key value pairs from an array of code pairs | ||
|
|
||
| Acceptance Criteria: | ||
|
|
||
| Given | ||
| - An array of arrays representing country code and currency code pairs | ||
| e.g. [['US', 'USD'], ['CA', 'CAD']] | ||
|
|
||
| When | ||
| - createLookup function is called with the country-currency array as an argument | ||
|
|
||
| Then | ||
| - It should return an object where: | ||
| - The keys are the country codes | ||
| - The values are the corresponding currency codes | ||
|
|
||
| Example | ||
| Given: [['US', 'USD'], ['CA', 'CAD']] | ||
|
|
||
| When | ||
| createLookup(countryCurrencyPairs) is called | ||
|
|
||
| Then | ||
| It should return: | ||
| { | ||
| 'US': 'USD', | ||
| 'CA': 'CAD' | ||
| } | ||
| */ | ||
| test("creates a country currency code lookup for multiple codes", () => { | ||
| // Given | ||
| const input = [ | ||
| ["US", "USD"], | ||
| ["CA", "CAD"], | ||
| ]; | ||
|
|
||
| const expectedOutput = { | ||
| US: "USD", | ||
| CA: "CAD", | ||
| }; | ||
|
|
||
| // When | ||
| const result = createLookup(input); | ||
|
|
||
| // Then | ||
| expect(result).toEqual(expectedOutput); | ||
| }); |
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(items) { | ||
| if (!Array.isArray(items)) { | ||
| throw new TypeError("Expected an array as input"); | ||
| } | ||
|
|
||
| return items.reduce((acc, item) => { | ||
| if (Object.hasOwn(acc, item)) { | ||
| acc[item] += 1; | ||
| } else { | ||
| acc[item] = 1; | ||
| } | ||
| return acc; | ||
| }, {}); | ||
| } | ||
|
|
||
| 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
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.