Created
September 10, 2016 18:19
-
-
Save kentquirk/abc19a77de1bbdff977855dc5cc951b1 to your computer and use it in GitHub Desktop.
Using lodash we can make it look like Python
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
// requires lodash.js | |
var output = {} | |
_.each(input, function(element){ | |
a = _.get(output, element.owner, []) | |
a.push(element.pet) | |
output[element.owner] = a | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment