Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

236
Vistas
Functional Programming, JavaScript, chaining, and no external library to calculate average on array of objects

I want to use Functional Programming, JavaScript, chaining, and no external library to reduce an array of objects to the average of the grade of the element with the condition that enrolled >1. So far I'm able to calculate the sum under the requested condition But how can I calculate the average? ( Note that I want to use Functional Programming, JavaScript, chaining, and no external library)

Here is what I have come so far ...

let enrollment= [
    {enrolled: 2, grade:100},
    {enrolled: 2, grade:80},
    {enrolled: 1, grade:89}
]

const sum = (accumulator, curr) => accumulator + curr.grade;


enrollment
    .filter( elem => elem.enrolled >1)
    .reduce(sum,0)

Now how do I chain an average function to the above block of code? Thanks in advance

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda