Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js find duplicates in array and count of numbers

const arr = ["a", "b", "c", "d", "e", "a", "b", "c", "f", "g", "h", "h", "h", "e", "a"]
const counts = {};
arr.forEach((x) => {
  counts[x] = (counts[x] || 0) + 1;
});
console.log(counts)
Source by thewebdev.info #
 
PREVIOUS NEXT
Tagged: #js #find #duplicates #array #count #numbers
ADD COMMENT
Topic
Name
9+2 =