Skip to content

Commit 0c8870b

Browse files
committed
corrections after review
1 parent b3b0ea7 commit 0c8870b

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Sprint-2/implement/contains.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ test("given an object with properties, returns false for non-existent property",
4343
// When passed to contains
4444
// Then it should return false or throw an error
4545
test("given invalid parameters like an array, returns false", () => {
46-
expect(contains([1, 2, 3], "a")).toEqual(false);
46+
expect(contains([1, 2, 3], "0")).toEqual(false);
4747
});

Sprint-2/implement/querystring.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ function parseQueryString(queryString) {
77

88
for (const pair of keyValuePairs) {
99
const index = pair.indexOf("=");
10+
if (index === -1) continue; // skip pairs with no "="
1011
const key = pair.slice(0, index);
1112
const value = pair.slice(index + 1);
13+
if (key === "") continue; // skip empty keys
1214
queryParams[key] = value;
1315
}
1416

Sprint-2/implement/tally.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ function tally(arr) {
44
}
55
const result = {};
66
for (const item of arr) {
7-
if (result[item]) {
8-
result[item]++;
9-
} else {
10-
result[item] = 1;
7+
if (Object.hasOwn(result, item)) {
8+
result[item]++;
9+
} else {
10+
result[item] = 1;
11+
}
1112
}
1213
}
1314
return result;
14-
}
1515

1616
module.exports = tally;

0 commit comments

Comments
 (0)