0

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.

jedians
  • 3
  • 1

1 Answers1

0

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));
Bibberty
  • 4,670
  • 2
  • 8
  • 23