I have a array of objects like these:
[
{
user: {
key1: ['1', '2', '3'],
},
},
{
user: {
key2: ['3', '4', '5'],
},
},
{
user2: {
key1: ['1', '2', '3'],
},
},
{
user2: {
key2: ['3', '4', '5'],
},
},
....
];
And I need to filter those by its keys and expecting an output like these
[
{
user: {
key1: ['1', '2', '3'],
key2: ['3', '4', '5'],
},
},
{
user2: {
key1: ['1', '2', '3'],
key2: ['3', '4', '5'],
....
}
}
]
Here user, user2 can be any key(userName) also key1, key 2 etc... may be any key(userActivity) with an array of string.
Here is the type of object:
[key: string]: {
[key: string]: string[];
};
}[];
Which will be the best way to filter this any help would be appreciated
user,user2or there could be more than one?