Created
October 24, 2019 04:32
-
-
Save kevinkace/9474caba27d78457b3ef81d5ba85d3b7 to your computer and use it in GitHub Desktop.
Reduce an object
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 objectReduce(obj, cb, acc) { | |
let idx = 0; | |
for (let key in obj) { | |
acc = cb(acc, { key, value : obj[key] }, idx++); | |
} | |
return acc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment