Created
September 10, 2016 17:05
-
-
Save kentquirk/0caacf8bfcd981d49be35eac5c7b7258 to your computer and use it in GitHub Desktop.
ES6-ready
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
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