I've been searching like this for quite some time now, and it seems there must be a more efficient approach. The scenario is that I have a double elimination tournament bracket and need to locate a specific game. The brackets for winners and losers are kept in an array with individual games stored within each of those arrays.
The format resembles the following:
{
tournament: {
brackets: [
{games: [{id:'x'},{id:'y'},...,{id:'z'}]},
{games: [{id:'x'},{id:'y'},...,{id:'z'}]}
]
]
}
}
Below is the code snippet I am currently using to identify an ID.
for (var i = 0; i < tournament.brackets.length; i++) {
for (var y = 0; y < tournament.brackets[i].games;length; y++) {
// Check if the ID matches the known ID
}
}