I have a JSON array and another array as follows.
JSON OBJECT
{
id: 1,
name: 'abc',
email: '[email protected]',
},
{
id: 2,
name: 'def',
email: '[email protected]',
},
SELECTED ARRAY
['id', 'email']
QUESTION
the selected array can have any key value of JSON Object what I want is JSON array should show the specific keys that are selected by a selected array
WHAT I TRIED
let jsonData = {};
let arr = [];
this.selectedExcelTitle.forEach((element) => {
var columnName = element;
jsonData[columnName] = this.Users.forEach((e) => {
return e.element;
});
});
arr.push(jsonData);