Using lodash, how could I group the names of people that have the same birthdates as seen below?
I wrote this out using nested for loops but was thinking there would be a more elegant way of doing this in lodash. I haven't used it much and trying to figure out which function to use.
[
{ "birthdate": "1993", "name": "Ben" },
{ "birthdate": "1994", "name": "John" },
{ "birthdate": "1995", "name": "Larry" },
{ "birthdate": "1995", "name": "Nicole" },
{ "birthdate": "1996", "name": "Jane" },
{ "birthdate": "1996", "name": "Janet" },
{ "birthdate": "1996", "name": "Dora" },
]
to
[
{ "birthdate": "1993", "names": [ "Ben" ] },
{ "birthdate": "1994", "names": [ "John"] },
{ "birthdate": "1995", "names": [ "Larry", "Nicole" ] },
{ "birthdate": "1996", "names": [ "Jane", "Janet", "Dora" ] }
]