<script>
const arr1 = [1, 2, 3, 4, 4, 10];
const arr2 = [1, 1, 1, 4, 5, 10];
const arr3 = [4, 10, 12];
function diffArray(arr1, arr2, arr3) {
// 请实现代码
arr4 = [];
arr1.forEach(item => {
arr2.forEach(item2 => {
arr3.forEach(item3 => {
if (item == item3 && item == item2) {
arr4.push(item);
}
});
});
});
return [...new Set(arr4)];
}
console.log(diffArray(arr1, arr2, arr3));
// 输出 [4, 10]
</script>
给你三个数组,请你输出三个数组里都有的数字
最新推荐文章于 2022-05-02 21:12:41 发布