I have an array of objects, and each objects may contain another array of objects, I want to concatenate values of nested array and generate a new array.
For example
lessons = [
{
id: 1,
description: string,
material: [{obj1}, {obj2}]
},
{
id: 2,
description: string,
material: [{obj3}]
},
{
id: 3,
description: string,
material: [{obj4}, {obj5}, {obj6}]
}
]
I want to generate a new array only contains material, expected output would like this
materials = [
{obj1},
{obj2},
{obj3},
{obj4},
{obj5},
{obj6}
]
how can I do that by using lodash?