Skip to content

Instantly share code, notes, and snippets.

@kentquirk
Last active September 10, 2016 17:00
Show Gist options
  • Save kentquirk/b87a6be0a26c0309dd3f740ee234f980 to your computer and use it in GitHub Desktop.
Save kentquirk/b87a6be0a26c0309dd3f740ee234f980 to your computer and use it in GitHub Desktop.
moreidiomatic.js
var output = {}
input.forEach(function(element) {
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