We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 27c9c9d commit ae23446Copy full SHA for ae23446
Sprint-2/implement/tally.js
@@ -3,7 +3,7 @@ function tally(arr) {
3
throw new Error();
4
}
5
6
- let result = {};
+ let result = Object.create(null);
7
8
for (const element of arr) {
9
if (element in result) {
Sprint-2/implement/tally.test.js
@@ -20,4 +20,9 @@ describe("tally", () => {
20
expect(() => tally(null)).toThrow();
21
expect(() => tally(undefined)).toThrow();
22
});
23
+
24
+ test("tally returns an object with no inherited properties", () => {
25
+ const result = tally(["a", "b", "a"]);
26
+ expect(Object.getPrototypeOf(result)).toBeNull();
27
+ });
28
0 commit comments