I have the following array of objects:
const datasubject =
[
0: {
level: "standard 3"
subject: "English"
_id: xxx
coreCompetencies {
0gHq0U5E667L4EdGbdZ2h: "Grammar",
9CfalSpzKYIV7AaWKBUwg: "Listening",
9boIfWUEGdj3WGxJL12XB: "Reading",
QZ11uYQ8CXkRk0LWenjqj: "Writing",
ZG1gtxRg6quIOYaTr6CUy: "Speaking"
}
},
1: {...},
2: {...}
]
I would like to change the coreCompetencies into an array of values e.g. ["Grammar", "Listening", "Reading", "Writing", "Speaking"] while preserving the other data. I've tried .map but got confused as it only returns the coreCompetencies object, without the other details. This is what I did that returned only the coreCompetencies object:
const datacore = datasubject.map(value => value.coreCompetencies);
I would like to achieve something like this:
const datasubject =
[
0: {
level: "standard 3"
subject: "English"
_id: xxx
coreCompetencies ["Grammar","Listening","Reading","Writing","Speaking"]
},
1: {...},
2: {...}
]