Skip to content

Commit 0877d2d

Browse files
author
russom
committed
if statement added to check the item is number not string.
1 parent af59161 commit 0877d2d

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎Sprint-2/implement/tally.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
function tally(arr) {
2+
if (!Array.isArray(arr)) {
3+
throw new Error("Invalid input");
4+
}
25
const count = {};
36
for (const item of arr) {
47
count[item] = (count[item] || 0) + 1;

0 commit comments

Comments
 (0)