Skip to content

Commit 95db997

Browse files
committed
updated tally code
1 parent b7eece4 commit 95db997

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎Sprint-2/implement/tally.js‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
function tally(arr) {
22
const result = arr.reduce((obj, item) => {
3-
if (obj [item]) {
3+
if (Object.hasOwn(obj, item)) {
44
obj[item] = obj[item] + 1;
5-
}
6-
else{
5+
} else {
76
obj[item] = 1;
87
}
9-
return obj;
8+
9+
return obj;
1010
}, {});
11-
11+
1212
return result;
1313
}
14-
module.exports = tally;
14+
15+
module.exports = tally;

0 commit comments

Comments
 (0)