I have a JS-array of objects, which looks like this:
const arr = [
{
"w": 2,
"h": 2,
"x": 0,
"y": 0,
"i": "SankeyChart_3_ae2cc",
"moved": false,
"static": false,
"children": []
},
{
"w": 6,
"h": 11,
"x": 0,
"y": 2,
"i": "GridWrapper_6_3d4c1", // parent elem
"moved": false,
"static": false,
"children": [
{
"w": 4,
"h": 6,
"x": 0,
"y": 0,
"i": "tooltip_119_50038",
"moved": false,
"static": false,
"children": []
},
{
"w": 2,
"h": 2,
"x": 1,
"y": 1,
"i": "Highchart_135_5de23", // child elem
"moved": false,
"static": false,
"children": []
}
]
}
]
For example, I have a value of Highchart_135_5de23
, which is a child elem of GridWrapper_6_3d4c1
. Is it possible to find the i
property of parent by knowing the i
propperty of child? I was able to create a function where parent i
prop is being passed directly to the function, but I now need it to be found, not hardcoded