My dilemma involves selecting the properties of an object based on certain values within the nested properties. I have been attempting to achieve this using Lodash's pick()
method, with the code looking something like this:
const object = {
a: {x: true, y: true,},
b: {x: true, y: false,},
c: {x: true, y: true,},
};
_.pick(object, y,);
The expected outcome should be as follows:
{
a: {x: true, y: true,},
c: {x: true, y: true,},
}
However, instead of the desired result, an error is encountered.
Execution halted due to Syntax Error on Line 6
Unexpected token, expected , (6:2)
I am puzzled by what mistake I may be making in this process.
Note: If there isn't a tidy solution available with Lodash, I am open to exploring an elegant plain Javascript alternative.