I don't think what I want is anything special, I just cant get my head round how to do it. I have an array of objects -
{
"year": 2016,
"some stuff": "bla0",
"other stuff": 20
},
"year": 2017,
"some stuff": "bla1",
"other stuff": 21
},
"year": 2016,
"some stuff": "bla2",
"other stuff": 22
}
I want to create the following array of objects from the above.
{
"2016": [
{
"year": 2016,
"some stuff": "bla0",
"other stuff": 20
},
{
"year": 2016,
"some stuff": "bla2",
"other stuff": 22
}
],
"2017": [
{
"year": 2017,
"some stuff": "bla1",
"other stuff": 21
}
]
}
My current WIP code is on https://codepen.io/sharperwebdev/pen/aqQQZy/?editors=1011 pertinent JS lines start at 167. Any help with getting my thinking straight on this would be appreciated.
forEachto the array at that property in the new object. Also, incidentally, it is sort of frowned upon to link out to a whole project. Read minimal reproducible example.