For example I have an array ["oranges", "apples", "people", "carrots"]
And I have ["oranges", "apples"] - I would like this to be true. But if it were ["oranges", "shoes"] - I would like this to be false.
For example I have an array ["oranges", "apples", "people", "carrots"]
And I have ["oranges", "apples"] - I would like this to be true. But if it were ["oranges", "shoes"] - I would like this to be false.
Use every
const masterArr = ["oranges", "apples", "people", "carrots"];
const arr1 = ["oranges", "apples"];
const arr2 = ["oranges", "shoes"];
const isMatch = (arr, master) => arr.every(e => master.includes(e));
console.log(isMatch(arr1, masterArr));
console.log(isMatch(arr2, masterArr));