I have to manipulate data in this wonderful language which is javascript. Until there I managed to achieve what I needed on my own but I reached my limits there.
It's quite hard to explain how my data is structured so let's make a schema. This is what I have :
obj: {[key: string]: {name: string, type: string}[]} =
{
"animals": [
{name: "Louis", type: "dog"},
{name: "John", type: "cat"},
{name: "Jordan", type: "dog"},
]
"cars" : [
{name: "alpha", type: "ferrari"},
{name: "beta", type: "ferrari"},
{name: "charlie", type: "mercedes"},
]
}
What I try to achieve is for each object, grouping the object in the list by type. This would look like this :
obj: {[key: string]: {[key: string]: {name: string, type: string}[]}} =
{
"animals": {
"dog": [
{name: "Louis", type: "dog"},
{name: "Jordan", type: "dog"},
],
"cat": [
{name: "John", type: "cat"},
]
}
"cars" : {
"ferrari": [
{name: "alpha", type: "ferrari"},
{name: "beta", type: "ferrari"},
],
"mercedes": [
{name: "charlie", type: "mercedes"},
]
}
}
Do you have any idea how to achieve that ?
Object.keys,.map(), etc.) you should edit your question and add your code, so we can help you improve it.