This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reduceAndFilter(input, keysToFilter){ | |
const result = input.reduce((acc, obj) => { | |
const objKeys = Object.keys(obj); | |
const filteredKeys = objKeys.filter(key => !keysToFilter.includes(key)); | |
filteredKeys.forEach(key => { | |
acc[key] = obj[key]; | |
}); | |
return acc; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const input = [ | |
{ personA: 'A', garbage: 'asldkfj' }, | |
{ personB: 'B', garbage: 'asldkfj' }, | |
{ personC: 'C', garbage: 'asldkfj' }, | |
{ personD: 'D', garbage: 'asldkfj' }, | |
{ personE: 'E', garbage: 'asldkfj' }, | |
{ personF: 'F', garbage: 'asldkfj' }, | |
{ personG: 'G', garbage: 'asldkfj' } | |
]; |