My question is about typescript and not javascript. I want to merge multiple arrays by key(id)
. For Example: I have these one to many relations arrays
Student Array 1 :
[
{
"Case ID":12,
"Student name":"john",
"address":"Ohio"
},
{
"Case ID":13,
"Student name":"David",
"address":"new york"
}
]
Courses Array 2 :
[
{
"id":34343,
"Case ID":12,
"course":"algorithm",
"Grade":"A"
},
{
"id":343434,
"Case ID":12,
"course":"advanced c++",
"Grade":"B"
}
]
I want to get this array which has keys from both array1 and array 2 :
`[
{
"Case ID":12,
"name":"john",
"Courses":[{"course":"algorithm",
"Grade":"A",},
{"course":"advanced c++",
"Grade":"B"}]
}
]`