let all = ['a', 'b', 'c', 'd', 'e'];
let bb = ['a', 'b']; //返回ture
let cc = ['b', 'f'];//返回ture
let dd = ['y', 'x'];//返回false
let ee = ['x'];//返回false
let ff = ['q', 'w','t', 'x'];//返回false
现有这两个数据,
如果bb中的某一项在aa中存在,返回 ture ,否则false。
let all = ['a', 'b', 'c', 'd', 'e'];
let bb = ['a', 'b']; //返回ture
let cc = ['b', 'f'];//返回ture
let dd = ['y', 'x'];//返回false
let ee = ['x'];//返回false
let ff = ['q', 'w','t', 'x'];//返回false
现有这两个数据,
如果bb中的某一项在aa中存在,返回 ture ,否则false。
function matchArray(arr1, arr2) {
return arr2.some(item => arr1.includes(item));
}
let all = ['a', 'b', 'c', 'd', 'e'];
console.log(matchArray(all, ['a', 'b'])); // true
console.log(matchArray(all, ['b', 'f'])); // true
console.log(matchArray(all, ['y', 'x'])); // false
console.log(matchArray(all, ['x'])); // false
console.log(matchArray(all, ['q', 'w','t', 'x'])); // false