var arr1 = [0, 1, 2, 3, 4, 5, 6];
var arr2 = [0, 2, 3, 4, 5, 6];
function getSome(arr1, arr2) {
let newArr = [];
for (let i = 0; i < arr2.length; i++) {
for (let j = 0; j < arr1.length; j++) {
if (arr1[j] === arr2[i]) {
newArr.push(arr1[j])
}
}
}
return newArr;//这个return一定要写上不能忘,之前就忘记写return然后就一直打印undefined
}
console.log(getSome(arr1, arr2));