I had the idea to develop a function that can count all the unique items in an array, but for some reason, I am not seeing any results.
Here is the array I am working with:
let arr = ["hi", "hello", "hi"];
This is the code snippet I have come up with so far:
function countUnique(arr) {
var counts = {};
for (var i = 0; i < arr.length; i++) {
counts[arr[i]] = 1 + (counts[arr[i]] || 0);
}
countUnique(arr);
}
console.log(countUnique(arr));