Useful “reduce” use cases
JP
1743

Hi. Nice article!

But, in the “Filter and Map” example, if performance matters, better use .push() instead of .concat(). It won’t create a new array on each tick:

const smartestStudents = studentsData.reduce(
(result, student) => {
if (student.score <= 80) {
return result;
}
    // Better
result.push(`${student.firstName} ${student.lastName}`)
return result
},
[]
);

Also, in the “Array to Object conversion” example, you can get rid of extra spread:

// Your
{ ...rules, ...{ [field.name]: field.constraints } }
// The same
{ ...rules, [field.name]: field.constraints }

Good luck!