I've been struggling to extract the last item from a nested array of objects. I've tried using methods like flatMap, flat, filter, and splice, but so far haven't had any luck getting the desired array.
const array = [
[
{
total_cases: 18,
},
{
total_cases: 32,
},
{
total_cases: 7,
},
],
[
{
total_cases: 4,
},
{
total_cases: 52,
},
],
[
{
total_cases: 68,
},
],
];
The provided array structure is shown above. Can anyone suggest a way to extract only the last object's total_cases value into a new array?
The expected new array should look like this:
[7, 52, 68]
Your assistance is greatly appreciated!