Answers for "write a js program to count total number of duplicate elements in an array."

1

counting duplicate values javascript

var counts = {};
your_array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });
Posted by: Guest on May-12-2020
0

duplicate numbers in an array javascript

[1, 1, 2, 2, 3].filter((element, index, array) => array.indexOf(element) !== index) // [1, 2]
Posted by: Guest on November-10-2020
0

how to count duplicates in an array javascript

arr.reduce((b,c)=>((b[b.findIndex(d=>d.el===c)]||b[b.push({el:c,count:0})-1]).count++,b),[]);
Posted by: Guest on December-16-2020

Code answers related to "write a js program to count total number of duplicate elements in an array."

Code answers related to "Javascript"

Browse Popular Code Answers by Language