y
Size: a a a
y
O
IC
4
j
S
S
O
j
NB
4
const students = [
{
id: 10,
name: 'John Smith',
marks: [10, 8, 6, 9, 8, 7]
},
{
id: 11,
name: 'John Doe',
marks: [ 9, 8, 7, 6, 7]
},
{
id: 12,
name: 'Thomas Anderson',
marks: [6, 7, 10, 8]
},
{
id: 13,
name: 'Jean-Baptiste Emanuel Zorg',
marks: [10, 9, 8, 9]
}
];
const getStudentAverage = id => {
const studentById = students.find(student => student.id === id)
const studentMarks = studentById.marks
return studentMarks.reduce((acc, mark) => acc + mark, 0) / students.length
}
getStudentAverage(10)
ス
NB
const students = [
{
id: 10,
name: 'John Smith',
marks: [10, 8, 6, 9, 8, 7]
},
{
id: 11,
name: 'John Doe',
marks: [ 9, 8, 7, 6, 7]
},
{
id: 12,
name: 'Thomas Anderson',
marks: [6, 7, 10, 8]
},
{
id: 13,
name: 'Jean-Baptiste Emanuel Zorg',
marks: [10, 9, 8, 9]
}
];
const getStudentAverage = id => {
const studentById = students.find(student => student.id === id)
const studentMarks = studentById.marks
return studentMarks.reduce((acc, mark) => acc + mark, 0) / students.length
}
getStudentAverage(10)
O
R
Nn
R