KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an array with repeating values. I would like to find the number of occurrences for any given value. For example, if I have an array defined as so: var dataset = [2,2,4,2,6,4,7,8]; , I want to find the number of occurrences of a certain value in the array. That is, the program should show that if I have 3 occurrences of the value 2 , 1 occurrence of the value 6 , and so on. What's the most idiomatic/elegant way to do this?
Tags (comma-separated)
Save Edits
Cancel