Created
March 9, 2019 17:05
-
-
Save theuves/9d8b1e778ae514da17f3904d78d1bdc5 to your computer and use it in GitHub Desktop.
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 filterObj(obj, cb) { | |
const newObj = {}; | |
const entries = Object.entries(obj); | |
for (entry of entries) { | |
const [key, val] = entry; | |
if (cb(key)) { | |
newObj[key] = val; | |
} | |
} | |
return newObj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment