-
-
Notifications
You must be signed in to change notification settings - Fork 149
West Midlands | ITP-MAY25 | Saleh Yousef | Module-Data-Groups | Sprint-2 #622
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 4 commits
80834dc
878d69e
bef438d
f63be1b
3cb3c9e
9505da4
41e83d6
1fc3cc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. Correct |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
function contains() {} | ||
function contains(obj, key) { | ||
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) { | ||
return false; | ||
} | ||
return Object.prototype.hasOwnProperty.call(obj, key); | ||
|
||
} | ||
|
||
module.exports = contains; |
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. tests passed |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
function createLookup() { | ||
// implementation here | ||
function createLookup(pairs) { | ||
const result = {}; | ||
|
||
for (const [countryCode, currencyCode] of pairs) { | ||
result[countryCode] = currencyCode; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
module.exports = createLookup; |
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. Tests passed |
SalehOmar-Y marked this conversation as resolved.
Show resolved
Hide resolved
|
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. test passed |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,21 @@ test("parses querystring values containing =", () => { | |
"equation": "x=y+1", | ||
}); | ||
}); | ||
|
||
test("parses querystring with multiple values", () => { | ||
expect(parseQueryString("name=John&age=30")).toEqual({ | ||
"name": "John", | ||
"age": "30", | ||
}); | ||
}); | ||
test("parses querystring with multiple values with same key", () => { | ||
expect(parseQueryString("name=John&name=Jane")).toEqual({ | ||
"name": "Jane", // Last value should overwrite previous ones | ||
}); | ||
}); | ||
|
||
test("parses querystring without key", () => { | ||
Comment on lines
+13
to
+26
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. Good edge cases! |
||
expect(parseQueryString("=Python")).toEqual({ | ||
"": "Python", // Empty key should be handled | ||
}); | ||
}); |
SalehOmar-Y marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
function tally() {} | ||
function tally(array) { | ||
if (!Array.isArray(array)) { | ||
throw new Error("Input must be an array"); | ||
} | ||
const counts = {}; | ||
|
||
for (const item of array) { | ||
if (counts[item]) { | ||
counts[item] += 1; | ||
} else { | ||
counts[item] = 1; | ||
} | ||
} | ||
|
||
return counts; | ||
} | ||
|
||
module.exports = tally; |
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. tests passed |
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. Both tests pass - well done |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Correct