Looking at the object structure in Chrome Dev Tools, it appears like this:
obj: {
1: {...},
2: {...},
3: {...},
4: {...},
5: {...},
}
On the other hand, there is a simple array as well:
arr: [1,3,5,7]
The goal here is to filter the object based on keys present in the array. For example:
obj: {
1: {...},
3: {...},
5: {...},
}
Currently, the code being used is:
var select = (arr, obj) => arr.reduce((r, e) =>
Object.assign(r, obj[e] ? { [e]: obj[e] } : null)
, {});
var output = select(arr, obj);
There seems to be sporadic issues with the functionality. It's important to note that JQuery cannot be utilized in this scenario. Any suggestions or assistance would be greatly appreciated.