const reducedfilter =(data, keys, func)=>{ data.filter(func).map(el =>{ keys.reduce((acc, key)=>{ acc[key] = el[key]; return acc },{}) ) } reducefilter(data, ['id', 'name'], item => item.age > 24)