Skip to content

Commit 04d19dd

Browse files
author
JorvanW
committed
removed unecessary comment
1 parent bdcc0fc commit 04d19dd

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

‎Sprint-2/implement/tally.js‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
function tally(array) {
2-
//(array) is the input to the function
3-
42
if (!Array.isArray(array)) {
5-
//checking if array is actually an array
63
throw new Error("Input must be an array");
74
}
85

96
if (array.length === 0) {
10-
//if array is empty return a empty array
117
return {};
128
}
139

14-
const result = {}; //creates result as an empty object which will store the counts
10+
const result = {};
1511

1612
for (const item of array) {
17-
//'for' loops through every item in the array
1813
if (result[item]) {
19-
// checks if the item is already in the result{}
2014
result[item]++;
21-
} // If it is then '++' tells it to add 1 to the value
22-
else {
23-
result[item] = 1; // else is saying that if it doesn't exist then we give it a value of 1
15+
} else {
16+
result[item] = 1;
2417
}
2518
}
2619

0 commit comments

Comments
 (0)