JSON data is something in this format.
[{
"_id": "5b706faf2605576fefb9ae9c",
"index": 0,
"guid": "46850469-5924-4966-b7d6-92125444cf98",
"isActive": true,
"balance": "$2,983.78",
"friends": [{
"fid": 0,
"fname": "Sondra Fields"
},
{
"fid": 1,
"fname": "Sondra"
},
{
"fid": 2,
"fname": "Fields"
}
],
"greeting": "Hello,",
"favoriteFruit": "apple"
}]
I am trying to get friends "fid" and "fname" but having the hard time doing so. I am doing something like this.
var dat = { array: data }
var actual = dat.array.reduce((p, n, index) => p.concat(n[index - 1]))
initially data is in "data" variable. by doing this console.log((actual.friends));
I got the following result.
[ { fid: 0, fname: 'Sondra Fields' },
{ fid: 1, fname: 'Sondra' },
{ fid: 2, fname: 'Fields' } ]
Unable to further extract the data. Thank you