Find duplicate element from n numbers of array in javascript

Viewed 28
'''
Array = [
    {
        Array1: [1, 2, 3, 4, 5],
    },
    {
        Array2: [2, 5, 8],
    },
    {
        Array3: [9, 10, 6],
    },
];
'''

expected result: if find any duplicate element from these arrays then return true otherwise false

I need to get duplicate elements from these arrays I need a solution in javascript

1 Answers
var array = [
    {
        Array: [1, 2, 3, 4, 5],
    },
    {
        Array: [2, 5, 8],
    },
    {
        Array: [9, 10, 6],
    },
];
let all:any=[]
let duplicate:any=[]
array.map(e=>{
    e.Array.map(el=>{
        if(all.includes(el)){
            if(!duplicate.includes(el)){
                duplicate.push(el)
            }
        }else{
            all.push(el)
        }
    })
})
console.log(duplicate)
Related