Skip to content

Instantly share code, notes, and snippets.

@katepapineni
Last active July 25, 2020 16:53
Show Gist options
  • Save katepapineni/34a02b314a9941d00ccbeda20e874d0b to your computer and use it in GitHub Desktop.
Save katepapineni/34a02b314a9941d00ccbeda20e874d0b to your computer and use it in GitHub Desktop.
const prices = { beer: 8, water: 1, latte: 4,
soda: 2, coffee: 3, wine: 12, };
function filter(prices) {
return Object.keys(prices).reduce((acc, key) => {
if (prices[key] % 2 === 0) {
delete acc[key];
}
return acc;
}, prices);
}
// What's the output?
console.log(filter(prices));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment