'how to check if an array contains the elements from a sub array

i want to check i an array contains the elements of any sub array, i.e. array1 = [10,11,12] array 2 = [[10, 11],[20, 21],[30, 31],[40, 41]];

array1 will be checked in series by each of array2's sub arrays and if the sub array elements are also in the array1 then to return true.

i've tried thing like:

      array2.some((arr) => {
        return arr.every((square) => {
          return array1.includes(square);
        });
      });

or

    for (let elem of array2) {
        if (elem.every((x) => array1.includes(x))) {
          return false;
        } else {
          return true;
        }
      }

any advice would be helpfull. thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source