const arry = [1, 2, 1, 3, 4, 3, 5]; const toFindDuplicates = arry => arry.filter((item, index) => arr.indexOf(item) !== index) const duplicateElementa = tofindDuplicates(arry); console.log(duplicateElements); // Output: [1, 3]