var myObject = {
word1: {
a: ['1.json', '2.json']
b: ['3.json', '4.json', '5.json']
},
word2: {
x: ['1.json', '3.json'],
y: ['2.json', '4.json'],
z: ['5.json']
}
}
So the output of this script should be:
['1.json', '4.json', '5.json']
Here is the logic, I want to be able to get the files that use the min stuff. Take for example "1.json", that one shows in:
myObject.word1.a
but also on
myObejct.word2.x
This means that '1.json' is no longer going to be used. But will be added to the output.
output so far: [1.json]
Here comes the tricky part.
Now lets go to '2.json'. It can't be used since 'myObject.word1.a' is already in use by '1.json', so just skip it.
output so far: [1.json]
Now lets go to '3.json', it appears on myobject.word1.b it apperas on myObject.word2.x // BUT 1.json already filled this position
So it can't be used
output so far: [1.json]
Lets go to 4.json it appears on myobject.word1.b it appears on myobject.word2.y <- here remember we skipped '2.json' since it did not work. So '4.json' is accepted
output so far: [1.json, 4.json]
lets go to 5.json it appears on myobject.word1.b it also appears on myobject.word2.z
this can be used since the "z" key has not been used by any other file.
5.jsoncan be used given thatword1.bis used by4.json