I am grappling with the following array of objects:
let a = [
{
b: [1, 11, 12],
c: "a1"
},
{
b: [2, 56, 1],
c: "a2"
},
{
b: [1, 2, 3],
c: "a3"
}
]
In search of an operation that is both simple and efficient, I wish to extract a second array from a
that contains only elements with values exceeding 10
in their b
arrays. For these selected elements, I want their corresponding b
arrays to include solely the values greater than 10
. The desired output is:
[
{
b: [11, 12],
c: "a1"
},
{
b: [56],
c: "a2"
}
]
While I could achieve this through traditional looping or using multiple steps such as filter()
, I am hopeful for a more streamlined one-line solution. Any recommendations?