Given n-number of collections/arrays, I would like to identify common elements and which collections they are common to.
This is a little bit similar to this question, however there could be similar elements in say, colletion1 and collection3, or even all of them. I am not only looking for elements similar in all collections. In addition I am open to using any Node.js libraries.
var arr["One"] = arrProps[{name: '1', prop2: 'aaa'}], arrValues['apple', 'orange', 'banana', 'pear', 'fish', 'pancake', 'taco', 'pizza'];
var arr["Two"] = arrProps[{name: '2', prop2: 'bbb'}], arrValues['taco', 'fish', 'apple', 'pizza', 'car'];
var arr["Three"] = arrProps[{name: '3', prop2: 'ccc'}], arrValues['banana', 'pizza', 'fish', 'apple', 'orange', ];
var arr["Four"] = arrProps[{name: '4', prop2: 'ddd'}], arrValues['grape', 'pear', 'chicken', 'car', 'orange'];
Result should be:
[arrValue, arrProps.name]
apple: 1,2,3
banana: 1,3
pear: 1,4
fish: 1,2,3
taco: 1,2
pizza: 1,3
car: 2,4
orange: 3,4
Rather than using arrays, if this were represented as a JSON graph, would that be any easier to solve, and if so, how?