Great example of using a hash table to tally and track data.
If you're interested, you could also use the Array sort() and filter() methods to quickly extract unique elements.
use the sort method to place all identical elements in adjacent indexes of a new array.
Use filter to generate another array which only includes elements which are different to the elements immediately before and after them in the sorted array (and are therefore unique).
Great example of using a hash table to tally and track data.
If you're interested, you could also use the Array sort() and filter() methods to quickly extract unique elements.
use the sort method to place all identical elements in adjacent indexes of a new array.
Use filter to generate another array which only includes elements which are different to the elements immediately before and after them in the sorted array (and are therefore unique).
Postscript
Removing duplicate items from your array
EG convert [1,2,2,1,4,8,8,9] to [1,2,4,8,9]
Create a new set from your original array and then spread the set into a new array.