Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Find / Display duplicate numbers in array

var input = [1, 2, 5, 5, 3, 1, 3, 1];
    var duplicates = input.reduce(function(acc, el, i, arr) {
    if (arr.indexOf(el) !== i && acc.indexOf(el) < 0) acc.push(el); return acc;
    }, []);
    console.log(duplicates);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Find #Display #duplicate #numbers #array
ADD COMMENT
Topic
Name
5+4 =