Match arrays in JavaScript
Check if array A has all elements of array B
let a = [1,2,3],
b = [1,2,3,4],
c = [1,2];
let checkEvery = (arr, target) => target.every(el => arr.includes(el));
console.log(checkEvery(b, a)) // true
console.log(checkEvery(c, a)) // false
Check if array A has any elements of array B
let a = [1,2,3],
b = [1,2,3,4],
c = [8,9];
let checkAny = (arr, target) => target.some(el => arr.includes(el));
console.log(checkEvery(b, a)) // true
console.log(checkEvery(c, a)) // false