Does anyone know of to group an array from the given object then create a new array of objects? For example, I have an array of student objects:
Keep the array with its object and adding subject into an array please help me out find the below example.
var metaData = [
{
"student_name":'john'
"student_class":'ten'
"age":'16'
"subject":'maths'
},
{
"student_name":'john'
"student_class":'ten'
"age":'16'
"subject":'science'
},
{
"student_name":'john'
"student_class":'ten'
"age":'16'
"subject":'arts'
},{
"student_name":'john'
"student_class":'ten'
"age":'16'
"subject":'soical'
},
{
"student_name":'john'
"student_class":'ten'
"age":'16'
"subject":'biology'
},
{
"student_name":'bellic'
"student_class":'ninth'
"age":'15'
"subject":'general knowleadge'
},
{
"student_name":'bellic'
"student_class":'ninth'
"age":'15'
"subject":'games'
},
{
"student_name":'bellic'
"student_class":'ninth'
"age":'15'
"subject":'computer'
},{
"student_name":'bellic'
"student_class":'ninth'
"age":'15'
"subject":'chemistry'
},
{
"student_name":'bellic'
"student_class":'ninth'
"age":'15'
"subject":'biology'
},
]
I want to make a new array of subjects array inside new array of objects`
var output:[
{
"student_name":'john'
"student_class":'ten'
"age":'16'
"subject":['maths','science','arts','soical','biology']
},
{
"student_name":'bellic'
"student_class":'ninth'
"age":'15'
"subject":['general knowleadge','games','computer','chemistry','biology']
}
]
I want to make it work with the function above.