DM
Size: a a a
DM
D
j
j
D
j
D
j
G
new
другой рез-тат?Р
j
Г
j
Г
G
DD
const students = [
{id:1, score:76 },
{id:2, score:80 },
{id:2, score:91 },
{id:1, score:100 },
{id:2, score:40 },
{id:2, score:64 },
{id:1, score:44 },
{id:1, score:55 },
{id:2, score:33 },
]
const id = 2
students.reduce((acc, student)=> {
console.log('acc = ', acc)
if (id === student.id) {
return acc.push(student)
}
return acc
},[])
j
const students = [
{id:1, score:76 },
{id:2, score:80 },
{id:2, score:91 },
{id:1, score:100 },
{id:2, score:40 },
{id:2, score:64 },
{id:1, score:44 },
{id:1, score:55 },
{id:2, score:33 },
]
const id = 2
students.reduce((acc, student)=> {
console.log('acc = ', acc)
if (id === student.id) {
return acc.push(student)
}
return acc
},[])
[].push(1)
возвращает 1 а не []DD
[].push(1)
возвращает 1 а не []с
Г