Kinda tricky question. I have this set of panels and I would like to make a function that would allow me to find the position in the array of this elements. However, in this array, there are subarrays. In this case, I just want to get the key of the parent array.
Example:
[
{
"name":"apple"
},
{
"name":"bone"
},
[
{
"name":"banana"
},
{
"name":"tea"
}
]
]
So, if I put apple in the function, it returns me 0, if I wanted to find the element with the name bone, it would return me the index 1 and if I wanted to find the index of banana, it would return me 2 and tea would also return me 2.
Anyone has an idea, how I can achieve this in a clean way?
Thanks!