Here is my student score json file :
(the idea is creating a function to change specific student score)
const classesData = [
{
name: 'A',
books: [
{ name: 'math' },
{ name: 'chemistry' },
{ name: 'physic' }
],
students: [
{
name: 'first student',
results: [
{ name: 'math', score: '20' },
{ name: 'chemistry', score: '14' },
{ name: 'physic', score: '16' },
]
},
{
name: 'second student',
results: [
{ name: 'math', score: '15' },
{ name: 'chemistry', score: '10' },
{ name: 'physic', score: '12' },
]
}
]
},
{
name: 'B',
books: [
{ name: 'math' },
{ name: 'chemistry' },
{ name: 'physic' }
],
students: [
{
name: 'first student',
results: [
{ name: 'math', score: '20' },
{ name: 'chemistry', score: '14' },
{ name: 'physic', score: '16' },
]
},
{
name: 'second student',
results: [
{ name: 'math', score: '15' },
{ name: 'chemistry', score: '10' },
{ name: 'physic', score: '12' },
]
}
]
}
]
How to do that?
For example
from class A change second student physic score to from 12 to 20
I’ve tried foreach and map but I didn’t get the result that I want