Last active
December 14, 2017 06:34
-
-
Save rc1021/b7d6a4cf4776ad3dcd1d237e810b8cb5 to your computer and use it in GitHub Desktop.
This file contains 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 _ = require('lodash'); | |
//Input | |
var input = [ | |
{ key: '1', val: 'a' }, | |
{ key: '2', val: 'b' }, | |
{ key: '3', val: 'c' } | |
]; | |
//Desired output | |
{ | |
'1': 'a', | |
'2': 'b', | |
'3': 'c' | |
} | |
//Current best solution | |
_.fromPairs(_.map(input, i => [i.key, i.val])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment