I have an existing array which is like this
"activeSubject": [
{
"subject_id": "Class Teacher",
"subject_name": "Class Teacher",
"status": "2"
},
{
"subject_id": "Academic Leader (Head)",
"subject_name": "Academic Leader (Head)",
"status": "2"
},
{
"subject_id": "15",
"subject_name": "Physics",
"status": "2"
}
]
I then want to create a new array which will be looking like this
"new_subjects": [
{
"value": "Class Teacher",
},
{
"value": "Academic Leader (Head)",
},
{
"value": "Physics",
}
]
I already have tried this by map()
method
var objA = this.state.activeSubject.map(o => ({
[o]: { value: o.subject_name}
}))
but it is not giving a proper array, please help me resolve this