Skip to content

Instantly share code, notes, and snippets.

@kentquirk
Created September 10, 2016 17:05
Show Gist options
  • Save kentquirk/0caacf8bfcd981d49be35eac5c7b7258 to your computer and use it in GitHub Desktop.
Save kentquirk/0caacf8bfcd981d49be35eac5c7b7258 to your computer and use it in GitHub Desktop.
ES6-ready
let output = {}
for (const element of input) {
if (output.hasOwnProperty(element.owner)) {
output[element.owner].push(element.pet)
} else {
output[element.owner] = [element.pet]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment