I have an object that looks like this:
sets: {
itemOne: {
importantThing: {
info: "",
},
otherThing: {},
otherThing: {},
etc...
},
itemTwo: {
importantThing: {
info: "",
},
otherThing: {},
otherThing: {},
etc...
},
etc...
}
I need to check if set.itemN.importantThing.info
exists in ANY of the unknown # of items, then compare that info to something else and show certain things on screen if it meets certain criteria.
My question is, is there a better way to do it than:
for set in sets
for element in item
if importantThing.info === 'something' { etc }
There is a lot of data that would need to be ignored, all the otherThing
s, and it feels like a waste of processing to have to loop through EVERYTHING just to get set.itemN.importantThing.info
The ultimate goal is, if ANY of the itemN
s have importantThing.info
set to a certain value, then something must be done, and the loop can stop.