Create a function that accepts an array and an item and counts the number of times that item shows up in the array. Do not ignore capitalization, punctuation, or spaces.
Examples:
itemCounter(["hello", [["Hello", "hello"], [["Hello"]], "Hello", "world"]], "hello"); // 2
itemCounter([["A", "A", "A", "A", "A", "a"],
["a", "A", "A", "A", "A", "A"],
["A", "a", "A", "A", "A", "A"],
["A", "A", "A", "a", "A", "A"]], "a"); // 4
itemCounter([1, 2, [3], [4, 5], [4, [[6, 7], 4]]], 4); // 3
itemCounter([1, 2, [3, 11], [4, 5], [4, [[6, 7], 4]]], 10) // 0
Top comments (0)