0

Just starting in JS and I'm looking for the basic syntax to extract the number of occurrences (i.e. how often # "2" is found in this array). Very basic but for some reason I'm stuck :(

var myArray = ["1", "5", "1", "1", "5", "2", "4", "5", "2", "3", "2", 
  "4", "2", "4", "2", "3", "2", "3", "2", "4", "2", "3", "2", "4", "2",
  "5", "1", "4", "2", "4", "2", "3", "2", "4", "1", "1", "5", "1", "1", 
  "1", "5", "2", "4", "5", "2", "3", "2", "4", "2", "4", "2", "3", "2", 
  "3", "2", "4", "2", "3", "2", "4", "2", "5", "1", "4", "2", "4", "2", 
  "3", "2", "4", "1", "1", "5", "1", "1", "5", "2", "4", "5", "2", "3", 
  "2", "4", "2", "4", "2", "3", "2", "3", "2", "4", "2", "3", "2", "4", 
  "2", "5", "1", "4", "2", "4", "2", "3", "2", "4", "1"];
Cerbrus
  • 70,800
  • 18
  • 132
  • 147
Rick
  • 1
  • 1
  • Also: [Counting the occurrences of JavaScript array elements](http://stackoverflow.com/questions/5667888/counting-the-occurrences-of-javascript-array-elements?noredirect=1&lq=1) – raina77ow Sep 22 '16 at 14:05
  • Thank you ... worked like a charm! – Rick Sep 22 '16 at 18:31

0 Answers0