-
-
Notifications
You must be signed in to change notification settings - Fork 283
London | 26-ITP-Jan | Miriam Jorna | Sprint 2 | Data Groups #1190
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 6 commits
b9c0a55
a3b820b
f5c978a
30de7d5
b3b0ea7
0c8870b
a12cf39
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, property) { | ||
| if (Array.isArray(obj) || typeof obj !== "object" || obj === null) { | ||
| return false; | ||
| } | ||
| return obj.hasOwnProperty(property); | ||
| } | ||
|
|
||
| module.exports = contains; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| function createLookup() { | ||
| // implementation here | ||
| function createLookup(pairs) { | ||
| 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 |
|---|---|---|
| @@ -1,3 +1,16 @@ | ||
| function tally() {} | ||
| function tally(arr) { | ||
| if (!Array.isArray(arr)) { | ||
| throw new Error("Input must be an array"); | ||
| } | ||
| const result = {}; | ||
| for (const item of arr) { | ||
| if (Object.hasOwn(result, item)) { | ||
| result[item]++; | ||
| } else { | ||
| result[item] = 1; | ||
| } | ||
|
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. Indentation is off. Have you installed the prettier VSCode extension and enabled "Format on save/paste" on VSCode, If you have successfully setup VSCode, you won't need to worry about manual indentation or trailing space.
Author
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. Thank you, this one is now also Prettified :) |
||
| } | ||
| } | ||
|
cjyuan marked this conversation as resolved.
|
||
| return result; | ||
|
|
||
| module.exports = tally; | ||
Uh oh!
There was an error while loading. Please reload this page.