Last active
July 25, 2020 16:53
-
-
Save katepapineni/34a02b314a9941d00ccbeda20e874d0b to your computer and use it in GitHub Desktop.
This file contains 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 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