const a = [1, 2, 3, 4, 6, 5, 5]
const b = [5, 6, 7, 8, 5, 6, 9]
function repeatElement(a, b) {
let arr1 = []
for (let i = 0; i < a.length; i++) {
for (let j = 0; j < b.length; j++) {
if (a[i] == b[j] && arr1.indexOf(a[i]) == -1) {
arr1.push(a[i])
}
}
}
return arr1
}
console.log(repeatElement(a, b))
const a = [1, 2, 3, 4, 6, 5, 5]
const b = [5, 6, 7, 8, 5, 6, 9]
function repeatElement1(a, b) {
let arr = []
for (let i = 0; i < a.length; i++) {
if (b.indexOf(a[i]) !== -1 && arr.includes(a[i]) == false) {
arr.push(a[i])
}
}
return arr
}
console.log(repeatElement1(a, b))