JSFiddle - React, Tailwind, and code Playground
by vikikamath
JavaScript
var network = {
1: [5,6,8,9],
2: [4,5,6,7,8,9],
3: [4,5,7,8],
4: [2,3,5,6,8,9],
5: [1,2,3,4,6,7,8,9],
6: [1,2,4,5,7,8],
7: [2,3,5,6],
8: [1,3,4,6],
9: [1,2,4,5]
};
console.log(network[2]);
console.log(network[7]);
var intersection = network[2].filter(function(arrElem){
return arrElem !== 5 && network[7].indexOf(arrElem) != -1;
});
console.log(intersection);