Created
September 7, 2019 15:08
-
-
Save tosipaulo/1ce81ecf42d4b71d9206e0592dd83b52 to your computer and use it in GitHub Desktop.
group key object
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
const captures = [ | |
{ | |
"placa": "NA123", | |
"data_hora": "07/05/2019 14:28:46" | |
}, | |
{ | |
"placa": "NA333", | |
"data_hora": "07/05/2019 14:28:46" | |
}, | |
{ | |
"placa": "NA123", | |
"data_hora": "07/05/2019 14:28:46" | |
}, | |
{ | |
"placa": "NA123", | |
"data_hora": "07/05/2019 14:28:46" | |
}, | |
{ | |
"placa": "NA222", | |
"data_hora": "07/05/2019 14:28:46" | |
}, | |
{ | |
"placa": "NA222", | |
"data_hora": "07/05/2019 14:28:46" | |
} | |
] | |
captures.reduce((group, item) => { | |
const val = item['placa'] | |
group[val] = group[val] || [] | |
group[val].push(item) | |
return group; | |
}, {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment