Skip to content

Commit 94caca5

Browse files
author
russom
committed
Update: ad Object.hasOwn for checking toString items.
1 parent 88c48a1 commit 94caca5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎Sprint-2/implement/tally.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ function tally(arr) {
44
}
55
const count = {};
66
for (const item of arr) {
7-
count[item] = (count[item] || 0) + 1;
7+
if (Object.hasOwn(count, item)) {
8+
count[item] = count[item] + 1;
9+
} else {
10+
count[item] = 1;
11+
}
812
}
913
return count;
1014
}

0 commit comments

Comments
 (0)