let data = [{
"ItemAID" : 1,
"ItemADesc" : [ {
"ItemBid" : 11,
"ItemBDesc" : [ {
"ItemCid" : 111,
"ItemCTitle" : "TitleC111",
}, {
"ItemCid" :112,
"ItemCTitle" : "TitleC112",
} ]
}]},
{
"ItemAID" : 2,
"ItemADesc" : [ {
"ItemBid" : 21,
"ItemBDesc" : [ {
"ItemCid" : 211,
"ItemCTitle" : "TitleC211",
}, {
"ItemCid" :212,
"ItemCTitle" : "TitleC212",
} ]
}]}]
console.log(data.find(A => A.ItemADesc.find(B => B.ItemBDesc.find(C=>C.ItemCid === 212)?.ItemCTitle)));
I want to retrieve the value of ItemCTitle when the itemCid matches a specific ID. The current code returns the entire object with matching itemCid, instead of just the nested variable value. Any help will be highly appreciated.