I have 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"
}
]
I want to do the simplest operation where I can return a second array that is a copy of a but includes only the elements whose b array contains at least one element greater than 10, and for each such element, have b contain only the element(s) greater than 10. So I want the output to be:
[
{
b: [11, 12],
c: "a1"
},
{
b: [56],
c: "a2"
}
]
I know I could do this naively with loops or in multiple steps using filter(), but I'm wondering if there's an efficient one-line solution.
Any tips?
.filter