Find the intersection of two arrays using node js

// Function to find the intersection of two arrays
function findIntersection(arr1, arr2) {
  return arr1.filter(value => arr2.includes(value));
}

// Example usage
const array1 = [1, 2, 3, 4, 5];
const array2 = [3, 4, 5, 6, 7];
const intersectionResult = findIntersection(array1, array2);
console.log(intersectionResult);

 

Post your Answer