I have this array of objects and I need to filter by the id and add the hours of each one.
const empleados = [
{id: '12345', nombre: 'Pedro', horas: 5},
{id: '1234', nombre: 'Jose', horas: 4},
{id: '123', nombre: 'Juan', horas: 7},
{id: '12345', nombre: 'Pedro', horas: 5},
{id: '1234', nombre: 'Jose', horas: 4}
];
The result should be
[ { id: '123', nombre: 'Juan', horas: 7 },
{ id: '1234', nombre: 'Jose', horas: 8 },
{ id: '12345', nombre: 'Pedro', horas: 10 } ]
If you can help me I thank you.