This is my Array in JavaScript, I want to merge teacher object below into combine single object to perform operations further.
const data = [
{
name: "ab",
class: 1,
grade: "A",
teacher: {
teacherName: "tab",
age: 34,
school: "ab pblc scl"
}
},
{
name: "cd",
class: 2,
grade: "B",
teacher: {
teacherName: "efg",
age: 35,
school: "cd pblc scl"
}
}
];
This is my Expected output. Here teacher object is combine with other single objects. Any idea how can I do this ?
const data = [
{
name: "ab",
class: 3,
grade: "B",
teacherName: "kio",
age: 38,
school: "ab pblc scl"
},
{
name: "de",
class: 2,
grade: "B",
teacherName: "tde",
age: 36,
school: "de pblc scl"
}
}
];
Any help will be appreciated