Created
May 26, 2018 18:05
-
-
Save WaldoJeffers/774142e2ea3e97fd3b126337b969d98f 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 obj = { books: 10, ruler: 1, pencils: 5 } | |
const isEven = x => Promise.resolve(x % 2 === 0) | |
const result = await Promise | |
.all(Object.values(obj).map(isEven)) | |
.then(results => Object.keys(obj).reduce((acc, key, index) => { | |
if (results[index]){ | |
acc[key] = obj[key] | |
} | |
return acc | |
}, {}) // { books: 10 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment