Skip to content

Commit 455d28d

Browse files
authored
Implement tally function to count item occurrences
1 parent 7c4bfb9 commit 455d28d

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎Sprint-2/implement/tally.js‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1-
function tally() {}
1+
function tally() {
2+
const counts = {};
3+
4+
for (const item of items) {
5+
if (counts[item] === undefined) {
6+
counts[item] = 1;
7+
} else {
8+
counts[item]++;
9+
}
10+
}
11+
12+
return counts;
13+
}
214

315
module.exports = tally;

0 commit comments

Comments
 (0)