If I had the following data, how would I go about filtering the students array in each node using ES6 syntax, so it only returns students that have a particular value in subjects (eg. subject = 'English')?
Data:
[
{
"node": {
"name": "Miss Jones",
"students": [
{
"name": "John",
"subjects": ["English", "Maths"]
},
{
"name": "Sarah",
"subjects": ["Geography"]
}
]
}
},
{
"node": {
"name": "Mr Hudson",
"students": [
{
"name": "Joe",
"subjects": ["Maths", "French"]
},
{
"name": "Samantha",
"subjects": ["English"]
}
]
}
}
]
Expected output:
[
{
"node": {
"name": "Miss Jones",
"students": [
{
"name": "John",
"subjects": ["English", "Maths"]
}
]
}
},
{
"node": {
"name": "Mr Hudson",
"students": [
{
"name": "Samantha",
"subjects": ["English"]
}
]
}
}
]
Thanks!