Skip to content

Instantly share code, notes, and snippets.

@hperantunes
Last active May 15, 2019 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hperantunes/7092dc6cfff9bee5ac8c897c349b8ce7 to your computer and use it in GitHub Desktop.
Save hperantunes/7092dc6cfff9bee5ac8c897c349b8ce7 to your computer and use it in GitHub Desktop.
export const sumObjects = (first, second) => Object.keys(second).reduce((object, key) => ({
...object,
[key]: (first[key] || 0) + (second[key] || 0)
}), {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment