I'm trying object destructuring to filter the data with new array but, it gives me the same data.
I would like to filter out object properties in order to have in the new array objects with only the following 3 properties: name, occupation, gender
Trying to get any advice.
const employee = [
{
name: 'sam',
occupation: 'designer',
gender: 'M',
email: 'sam.camp@around.com',
salary: 40000,
location: 'Canada'
},
{
name: 'sara',
occupation: 'developer',
gender: 'M',
email: 'sara.cap@around.com',
salary: 30000,
location: 'USA'
},
];
function filterData(arr) {
arr.map(( name, occupation, gender ) => ({ name, occupation, gender }));
return arr
}
console.log(filterData(employee));