JS массивы проверьте, есть ли перекресток

// Use a combination of Array.prototype.filter and Array.prototype.includes:
const filteredArray = array1.filter(value => array2.includes(value));
GutoTrosla