JSFiddle - React, Tailwind, and code Playground

by vaheed akhtar

JavaScript

let nums1 = [1,2,2,1], nums2 = [2];


function findIntersec(nums1, nums2) {
return nums1.length > nums2.length && nums1.filter((n1) =>  nums2.find((n2) => n1 === n2));
}
console.log(findIntersec(nums1, nums2));