Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how many times one element is reapete of an array in js

uniqueCount = ["a","b","c","d","d","e","a","b","c","f","g","h","h","h","e","a"];
var count = {};
uniqueCount.forEach(function(i) { count[i] = (count[i]||0) + 1;});
console.log(count);
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #times #element #reapete #array #js
ADD COMMENT
Topic
Name
1+9 =