Hello, I need some assistance.
I have a couple of arrays containing grades with associated classes attributes like the examples below:
var arr1 = [{
"id": 53,
"name": "Grade 1 AppMonkeyzTest",
"classes": [{
"id": 54,
"name": "Class 1A AppMonkeyzTest"
}, {
"id": 55,
"name": "Class 1B AppMonkeyzTest"
}, {
"id": 59,
"name": "Class BG1 AppMonkeyzTest"
}]
}, {
"id": 54,
"name": "Grade 2 AppMonkeyzTest",
"classes": [{
"id": 56,
"name": "Class AA1 ppMonkeyzTest"
}, {
"id": 57,
"name": "Class BA1 AppMonkeyzTest"
}]
}];
and
var arr2 = [{
"id": 53,
"name": "Grade 1 AppMonkeyzTest",
"classes": [{
"id": 58,
"name": "Class BB1 AppMonkeyzTest"
}]
}];
My goal is to combine them into a single array of grades with unique classes for each grade ID, as shown below:
var merge = [
{
"id": 53,
"name": "Grade 1 AppMonkeyzTest",
"classes": [{
"id": 54,
"name": "Class 1A AppMonkeyzTest"
}, {
"id": 55,
"name": "Class 1B AppMonkeyzTest"
}, {
"id": 59,
"name": "Class BG1 AppMonkeyzTest"
}, {
"id": 58,
"name": "Class BB1 AppMonkeyzTest"
}]
},
{
"id": 54,
"name": "Grade 2 AppMonkeyzTest",
"classes": [{
"id": 56,
"name": "Class AA1 ppMonkeyzTest"
}, {
"id": 57,
"name": "Class BA1 AppMonkeyzTest"
}]
}];