You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
314 B
JavaScript

"use strict";
module.exports = function doArraysIntersect(arrayA, arrayB) {
let oneSet, otherArray;
if (arrayA.length > arrayB.length) {
oneSet = new Set(arrayA);
otherArray = arrayB;
} else {
oneSet = new Set(arrayB);
otherArray = arrayA;
}
return otherArray.some((item) => oneSet.has(item));
};