Skip to content

Instantly share code, notes, and snippets.

@kevinkace
Created October 24, 2019 04:32
Show Gist options
  • Save kevinkace/9474caba27d78457b3ef81d5ba85d3b7 to your computer and use it in GitHub Desktop.
Save kevinkace/9474caba27d78457b3ef81d5ba85d3b7 to your computer and use it in GitHub Desktop.
Reduce an object
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