Using javascript only, is there a way to locate a property within an array that is itself within another array and return its "path"?
Imagine a hierarchical group of nested arrays much like this example:
var bigBox = [
mediumBoxA = [
smallBoxA = [
toyA = { toyId : "Blue Ball"},
toyb = { toyId : "Pink Ball"}
],
smallBoxB = [
toyA = { toyId : "Girl Doll"},
toyB = { toyId : "Boy Doll"}
],
],
mediumBoxB = [
smallBoxA = [
toyA = { toyId : "Batman"},
toyB = { toyId : "Superman"}
],
smallBoxB = [
toyA = { toyId : "Lego"},
toyB = { toyId : "Soldier"}
],
]
];
Given that, in the console I want to be able to search for example: "Batman" and get that it is located in bigBox > mediumBoxB > smallBoxA > toyA. Again, I'm looking for a JS only solution and something I can implement on the console. No HTML involved.
Now, I know that i could go only by the index number, I used labels on each array such as "smallBox", "toyB", etc.. for explanation purposes.
Thank you guys!