[javascript] How to count certain elements in array?