-
-
Notifications
You must be signed in to change notification settings - Fork 272
London | 26-ITP-Jan | Maryanne Mosonik | Sprint 2 | Module Data Groups #1101
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
base: main
Are you sure you want to change the base?
Changes from all commits
6393ef5
e6bacd4
c2ab2f1
109bcc2
af85892
bfb9753
9b83c73
51b68eb
6e8e4ce
20f1d05
5596d68
16b8b68
81f932b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| function contains() {} | ||
| function contains(obj, key) { | ||
| if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) { | ||
| return false; | ||
| } | ||
| return key in obj; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider the following two approaches for determining if an object contains a property: Which of these approaches suits your needs better? |
||
| } | ||
|
|
||
| module.exports = contains; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| function createLookup() { | ||
| function createLookup(pairs) { | ||
| // implementation here | ||
| const lookup = {}; | ||
| for (const [country, currency] of pairs) { | ||
| lookup[country] = currency; | ||
| } | ||
| return lookup; | ||
| } | ||
|
|
||
| module.exports = createLookup; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,10 +6,15 @@ function parseQueryString(queryString) { | |
| const keyValuePairs = queryString.split("&"); | ||
|
|
||
| for (const pair of keyValuePairs) { | ||
| const [key, value] = pair.split("="); | ||
| queryParams[key] = value; | ||
| const index = pair.indexOf("="); | ||
| if (index === -1) { | ||
| queryParams[pair] = ""; | ||
| } else { | ||
| const key = pair.substring(0, index); | ||
| const value = pair.substring(index + 1); | ||
| queryParams[key] = value; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: (No change required)
|
||
| } | ||
| } | ||
|
|
||
| return queryParams; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,16 @@ | ||
| function tally() {} | ||
| function tally(arr) { | ||
| if (!Array.isArray(arr)) { | ||
| throw new Error("Input must be an array"); | ||
| } | ||
| const counts = {}; | ||
| for (const item of arr) { | ||
| if (counts[item]) { | ||
| counts[item] += 1; | ||
| } else { | ||
| counts[item] = 1; | ||
| } | ||
| } | ||
|
Comment on lines
+5
to
+12
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the following function call returns the value you expect? Suggestion: Look up an approach to create an empty object with no inherited properties. |
||
| return counts; | ||
| } | ||
|
|
||
| module.exports = tally; | ||
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.
The requirement on line 4 has not yet been met: