Javascript count number of occurrences in array