¡Te damos la bienvenida a este reto!

1

¡Bienvenido al mundo de JavaScript!

Día 1

2

Variables, funciones y sintaxis básica

3

Tipos de datos

4

Playground - Retorna el tipo

5

Tipos de datos - pt 2

Día 2

6

Operadores

7

Hoisting y coerción

8

Playground - Calcula la propina

9

Alcance de las variables

Día 3

10

Condicionales

11

Playground - Calcula años bisiestos

12

Switch

13

Playground - Obten información de mascotas según su tipo

14

Ciclos

15

Playground - Dibuja un triangulo

Día 4

16

Arrays

17

Playground - Encuentra al michi mas famoso

18

Objetos

19

Playground - Obten el promedio de los estudiantes

Día 5 - Checkpoint

20

Playground - encuentra el palindromo más grande

Día 6

21

Reasignación y redeclaración

22

Modo estricto

Día 7

23

Debugging y manejo de errores

24

Programación funcional

Quiz: Día 7

Día 8

25

Closures

26

Playground - Crea una calculadora con closures

27

Higher order functions

28

Playground - Crea tu propio método map

Día 9

29

ECMAScript

30

TC39

Quiz: Día 9

Día 10 - Checkpoint

31

ES6

32

ES7

33

Playground - Task planner

Día 11

34

Asincronismo

35

Playground - Promesas

36

Manejando el asincronismo

37

Playground - Resuelve el callback hell usando promesas

38

Playground - Resuelve el callback hell usando async/await

Día 12

39

Arrays a profundidad

40

Métodos de arrays: Every, Find y findIndex

41

Playground - Válida el formulario

Día 13

42

Métodos de arrays: Includes, Join y concat

43

Playground - agrupa los productos

44

Métodos de arrays: Flat y FlatMap

45

Playground - Encuentra la ubicación del valor buscado

Día 14

46

Mutable functions

47

Playground - Modifica una lista de compras

48

Métodos de arrays: sort

49

Playground - Ordena los productos

Día 15 - Checkpoint

50

Playground - Sistema de reservaciones de un hotel

Día 16

51

Programación orientada a objetos en JavaScript

52

Objetos literales

53

Playground - Congela el objeto recursivamente

Día 17

54

Prototipos en JavaScript

55

Playground - Modifica el prototype de los arrays

56

Playground - Crea un auto usando clases

Día 18

57

Abstracción en JavaScript

58

Playground - Sistema de carrito de compras

59

Encapsulamiento en JavaScript

60

Playground - Encapsula datos de los usuarios

Día 19

61

Herencia en JavaScript

62

Playground - Jerarquía de animales

63

Polimorfismo en JavaScript

64

Playground - Sistema de pagos

Día 20 - Checkpoint

65

Playground - Agenda de vuelos

Día 21

66

Patrones de diseño

67

Sinlgeton y Factory pattern en JavaScript

68

Playground - Implementa singleton en un chat

Día 22

69

Adapter y Decorator pattern en JavaScript

70

Playground - Personaliza productos de una tienda

71

Builder y Protype pattern en JavaScript

72

Playground - Mejora el código usando builder pattern

Día 23

73

Facade y proxy pattern en JavaScript

74

Playground - Proxy en servicio de mensajería

75

Chain of responsability y Observer pattern en JavaScript

76

Playground - Implementación de Observador en Newsletter

Día 24 - Checkpoint

77

Playground - Crea un task manager con patrones de diseño

Día 25

78

Estructuras de datos en JavaScript

79

Playground - Crea tu propia implementación de un array

80

Hash tables en JavaScript

81

Playground - Implementación de una HashTable para Contactos

Día 26

82

Set en JavaScript

83

Playground - Remueve duplicados de una lista

84

Maps en JavaScript

85

Playground - Crea un organizador de tareas

Día 27

86

Singly Linked List en JavaScript

87

Playground - Agrega métodos a la singly linked list

88

Playground - Implementación de una singly linked list

Día 28

89

Stacks en JavaScript

90

Playground - Crea un stack para una playlist

Día 29

91

Queues en JavaScript

92

Playground - Crea una cola de emails

Día 30

93

¡Lo lograste!

Live Class

94

30 días de JS con Juan DC

95

30 días de JS con Nicobytes

96

30 días de JS con GNDX

97

30 días de JS con LeoCode

98

30 días de JS con Teffcode

99

Sesión: Cierre de los 30 días de JavaScript

No tienes acceso a esta clase

¡Continúa aprendiendo! Únete y comienza a potenciar tu carrera

Playground - Obten el promedio de los estudiantes

19/99

Aportes 140

Preguntas 5

Ordenar por:

¿Quieres ver más aportes, preguntas y respuestas de la comunidad?

🛡️Escudo anti spoilers🛡️

.
A este punto espero ya entiendas cual es el propósito de este texto, y si no, igual lo pongo para hacer espacio en este comentario (no olvides darle like).
.
Este es un comentario para aquellos y aquellas estudiantes que sea su primera vez resolviendo este coding playground y evites auto spoilearte viendo las soluciones de la comunidad (por favor SIGAN compartiendo sus soluciones, nos fascina ver como lo hacen). A su vez, este comentario tendrá la explicación a este problema más abajo, abajo del gif random que siempre suelo poner por lo que ya sabes que esperar si haces más scroll
.
Momento random del día

.

Explicación

En este caso, no optamos por usar bucles. En su lugar fueron métodos propios de los arrays (para variar con las soluciones pero facilmente puede hacerse con un for o un while, for of, etc…)

export function getStudentAverage(students) {
  // Creamos un array donde obtendremos los estudiantes con su promedio
  const studentsWithAverage = students.map((student) => {
    // separamos las notas en una sola variable para hacerlo más legible
    const grades = student.grades;
    // calculamos el promedio sumando todas las notas para dividirlas
    // en el total de materias
    const average =
      grades.reduce((total, item) => total + item, 0) / grades.length;

    return {
      // Retornamos un objeto con el nombre del estudiante
      name: student.name,
      // Junto con su promedio a 2 decimales
      // Es importante parsearlo con Number porque el método toFixed devuelve un string
      average: Number(average.toFixed(2)),
    };
  });

  // Después pasamos a hacer lo mismo pero obteniendo el promedio de la clase
  const classAverage =
    studentsWithAverage.reduce((total, student) => total + student.average, 0) /
    studentsWithAverage.length;
  // Sumamos todos los promedios y los dividimos entre el total de estudiantes

  // Al final armamos un objeto que será el que retornaremos
  const rta = {
    // De igual manera pasamos el promedio de la clase a 2 decimales
    classAverage: Number(classAverage.toFixed(2)),
    students: studentsWithAverage,
  };

  // Y retornamos el objeto anterior
  return rta;
}

Y ¡listo!
.
Si llegaste a esta parte de la lectura te comparto un fun fact, esta solución fue propuesta por el gran Nicobytes, mi solución era otra pero esta se ve más coqueta.
.
No olvides dejar tu corazoncito

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let total = 0;
  const course = {
    classAverage: 0,
    students: []
  };
  for (const student of students) {
    let sum = student.grades.reduce((sum, grade) => sum + grade);
    let averageStudent = (sum / student.grades.length).toFixed(2);
    const aStudent = {
      name: student.name,
      average: Number(averageStudent)
    }
    course.students.push(aStudent);
    total += Number(averageStudent);
  }
  course.classAverage = Number((total / students.length).toFixed(2));
  return course;
}

Por favor no más loops dentro de loops, me estoy lastimando 😦

export function getStudentAverage(students) {
  // Tu código aquí 👈
  const studensAverageGrades = students.map(({ name, grades }) => ({
    name: name,
    average: +((grades.reduce((acc, cur) => acc += cur, 0) / grades.length).toFixed(2))
  }))

  return {
    classAverage: +(studensAverageGrades.reduce((acc, cur) => acc += cur.average,0)/studensAverageGrades.length).toFixed(2),
    students: studensAverageGrades
  }
}

Hey dude, aqui mi solución :

function getStudentAverage(students) {
  //Primero, creamos una variable totalAverage que utilizaremos para acumular los promedios individuales de cada estudiante
  let totalAverage = 0;
  //Luego, iteramos a través del array de estudiantes usando el método map() y calculamos el promedio de cada estudiante usando el método reduce().
  const studentAverages = students.map(student => {
    const average = student.grades.reduce((sum, grade) => sum + grade, 0) / student.grades.length;
    //Dentro del map(), también agregamos el promedio del estudiante a la variable totalAverage y redondeamos el promedio a dos decimales usando el método toFixed().
    totalAverage += average;
    return {
      name: student.name,
      average: Number(average.toFixed(2))
    };
  });
  //Después de calcular los promedios individuales de cada estudiante, calculamos el promedio de la clase dividiendo totalAverage por la cantidad de estudiantes y redondeando el resultado a dos decimales.
  const classAverage = Number((totalAverage / students.length).toFixed(2));
  //Creamos el objeto de salida con los valores correspondientes y lo retornamos.
  return {
    classAverage: Number(classAverage),
    students: studentAverages
  };
}

Genial.

Aquí mi solución:

export function getStudentAverage(students) {
  const final = { classAverage: 0, students: [] };
  const arrayPromedioFinal = [];
  let promedioFinal;

  for (let objeto of students) {
    const promedio = objeto["grades"].reduce((a, b) => a + b);
    arrayPromedioFinal.push(Number((promedio / objeto["grades"].length).toFixed(2)));
    promedioFinal = arrayPromedioFinal.reduce((a, b) => a + b) / students.length;
    final.classAverage = Number(promedioFinal.toFixed(2));
    final.students.push(
      {
        name: objeto.name,
        average: Number((promedio / objeto["grades"].length).toFixed(2)),
      },
    );
  };

  return final;
}

Saludos comunidad platzi lo resolví de esta manera:

export function getStudentAverage(students) {
  let sumapromedios = 0;
  let promediados = students.map((student) => {
    const promedio = Number((student.grades.reduce((sum, value) => sum + value, 0) / student.grades.length).toFixed(2));
    sumapromedios += promedio;
    return { name: student.name, average: promedio, };
  })
  const nuevalista = { classAverage: Number((sumapromedios / students.length).toFixed(2)), students: promediados };
  return nuevalista;
}
Reto cumplido xd: ```js export function getStudentAverage(students) { let datoEstudiante = []; for (var estudiante of students) { datoEstudiante.push({ name: estudiante.name, average: parseFloat(((estudiante.grades.reduce((a, b) => a + b, 0)) / estudiante.grades.length).toFixed(2)) }); } const object = { classAverage: parseFloat(((students.reduce((a, b) => a + b.grades.reduce((a, b) => a + b, 0), 0)) / students.reduce((a, b) => a + b.grades.length, 0)).toFixed(2)), students: datoEstudiante }; return object; } ```
no se porque qaui no me corre pero esta fue mi solucion: ```js export function getStudentAverage(students) { let promedioEstudiante; let promedioClase = 0; for (let i = 0; i < students.length; i++) { promedioEstudiante = +((students[i].grades.reduce((acumulador, nota) => acumulador + nota, 0) / students[i].grades.length).toFixed(2)); students[i].grades = promedioEstudiante; promedioClase += promedioEstudiante; } promedioClase = +((promedioClase / students.length).toFixed(2)); let respuesta = { classAverage: promedioClase, students: students, } return respuesta; }; ```export function getStudentAverage(students) {  let promedioEstudiante;  let promedioClase = 0;  for (let i = 0; i < students.length; i++) {    promedioEstudiante = +((students\[i].grades.reduce((acumulador, nota) => acumulador + nota, 0) / students\[i].grades.length).toFixed(2));    students\[i].grades = promedioEstudiante;    promedioClase += promedioEstudiante;   }  promedioClase = +((promedioClase / students.length).toFixed(2));   let respuesta = {    classAverage: promedioClase,    students: students,  }   return respuesta;};
En mi editor funciona pero no se por que aqui no: ```js let clase = [ { name: "Pedro", grades: [90, 87, 88, 90], }, { name: "Jose", grades: [99, 71, 88, 96], }, { name: "Maria", grades: [92, 81, 80, 96], }, { name: "Mara", grades: [92, 81, 80, 96], }, { name: "Mana", grades: [92, 81, 80, 96], }, ]; let students = [...clase]; let classAverage = 0; for (i = 0; i < clase.length; i++) { let studentAverage = +((clase[i].grades.reduce((acumulador, item) => acumulador + item, 0) / clase[i].grades.length).toFixed(2)); students[i].grades = studentAverage; classAverage += studentAverage; } classAverage = (classAverage / clase.length).toFixed(2); let respuesta = {"classAverage": classAverage, "students": students}; return (respuesta); ```
```js function getStudentAverage(students) { let final_students = []; let total_average = 0; for (student of students) { let average = (student["grades"].reduce((total, suma) => { return total += suma; }, 0 ) / (students.length + 1) ).toFixed(2); total_average += parseFloat(average); final_students.push({ name: student["name"], average: parseFloat(average) }); } total_average = parseFloat((total_average / students.length).toFixed(2)); return { classAverage: total_average, students : final_students }; } ```function getStudentAverage(students) { let final\_students = \[]; let total\_average = 0; for (student of students) { let average = (student\["grades"].reduce((total, suma) => { return total += suma; }, 0 ) / (students.length + 1) ).toFixed(2); total\_average += parseFloat(average); final\_students.push({ name: student\["name"], average: parseFloat(average) }); } total\_average = parseFloat((total\_average / students.length).toFixed(2)); return { classAverage: total\_average, students : final\_students }; }

Mi solución, quizá no muy legible:

export function getStudentAverage(students) {
  let studentsAvg = students.map(student => {
    return {
      name: student.name,
      average: parseFloat((student.grades.reduce(
        (sumTotal, grade) => {
          return sumTotal + grade;
        }, 0
      ) / student.grades.length).toFixed(2))
    };
  });

  return {
    classAverage: parseFloat((studentsAvg.reduce(
      (sumTotal, student) => {
        return sumTotal + student.average;
      }, 0
    ) / studentsAvg.length).toFixed(2)),
    students: studentsAvg
  };
}
Este fue mi código inicial, el cual **funciona perfectamente** y cumple con el propósito para esta función. Sin embargo, tuve que hacer algunas modificaciones para que este pudiera funcionar en las pruebas del reto, ya que requiere algunas condiciones muy especificas. Igual se los comparto porque explica muy bien la lógica que se ejecuta en estos cálculos. ![](https://static.platzi.com/media/user_upload/Screenshot%202023-10-04%20at%201.19.59%20PM-22d37d0d-4bc8-4f64-92ca-7effa8057ec0.jpg)

TOME ASIENTO POR FAVOR, QUE LA SOLUCIÓN ESTÁ MÁS ABAJO:

function getStudentAverage(students) {
  let generalAverage = {};
  let sumGrades = [];
  let averages = [];
  let classAverage;
  for (let i = 0; i < students.length; i++) {
    sumGrades[i] = students[i].grades.reduce((a, b) => a + b);
  }
  averages = sumGrades.map(element => Number((element / students[0].grades.length).toFixed(2)));
  console.log(averages);
  classAverage = Number(((averages.reduce((a, b) => a + b)) / students.length).toFixed(2));
  generalAverage.classAverage = classAverage;
  generalAverage.students = [];
  for (let j = 0; j < averages.length; j++) {
    generalAverage.students[j] = {};
    generalAverage.students[j].name = students[j].name;
    generalAverage.students[j].average = averages[j];
  }
  return generalAverage;
} 

Yo hice esto, pero al correr las pruebas la toma como malo cuando en realidad está bueno:

getStudentAveragedato = [
  {
    name: "Pedro",
    grades: [90, 87, 88, 90],
  },
  {
    name: "Jose",
    grades: [99, 71, 88, 96],
  },
  {
    name: "Maria",
    grades: [92, 81, 80, 96],
  },
];

function getStudentAverage(students) {
    const newobject = {
    classAverage: 0,
    students: [],
  };
  let sumprom = 0;
  for (i = 0; i < students.length; i++) {
    const suma = (students[i].grades.reduce((total, item) => total + item, 0))/students[i].grades.length;
    sumprom = sumprom + suma;
    newobject.students.push({ name: students[i].name, average: suma });
  }
  newobject.classAverage = Number((sumprom / students.length).toFixed(2));
  return newobject;
}
getStudentAverage(getStudentAveragedato);

🛡️🛡️🛡️Escudo anti spoilers🛡️🛡️🛡️

Obtén el promedio de los estudiantes

function getStudentAverage(students) {
  // Tu código aquí 👈
  const result = {}

  result.students = students.map((student) => {
      const sum = student.grades.reduce((accu, curr) => accu + curr)
      const size = student.grades.length
      return {
        name: student.name,
        average: parseFloat((sum/size).toFixed(2))
      }
  })
  
  result.classAverage=result.students.reduce((accu, curr) => {
    accu += curr.average
    return accu
  }, 0) / result.students.length

  result.classAverage = parseFloat(result.classAverage.toFixed(2))

  return result;
}

console.log(
  getStudentAverage([
    {
      name: "Pedro",
      grades: [90, 87, 88, 90],
    },
    {
      name: "Jose",
      grades: [99, 71, 88, 96],
    },
    {
      name: "Maria",
      grades: [92, 81, 80, 96],
    },
  ])
);

function getStudentAverage(students) {
  let sumTotal = 0;
  const groupStudents = students.reduce((acc, el) => {
    const sumGrades = el.grades.reduce((a, b) => a + b);
    const average = Number((sumGrades / el.grades.length).toFixed(2));
    sumTotal += average;
    acc.push({ name: el.name, average });
    return acc
  }, []);
  return {
    classAverage: Number((sumTotal / students.length).toFixed(2)),
    students: [...groupStudents]
  }
}

mi aporte

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let claseNotas = {
    classAverage: 0,
    students: []
  };

  let objectTemp = {
    name: '',
    average: 0
  };
  let acumulador = 0;
  let cantidadNotas = 0;
  let acumuladorGeneral = 0;

  for (let j = 0; j < students.length; j++) {
    acumulador = students[j].grades.reduce((accumulator, currentValue) => {
      return accumulator + currentValue;
    }, 0);

    cantidadNotas = students[j].grades.length;

    objectTemp = {
      name: students[j].name,
      average: Number((acumulador / cantidadNotas).toFixed(2))
    };

    claseNotas.students.push(objectTemp);
    console.log(acumulador);
    acumuladorGeneral += objectTemp.average;

  }

  claseNotas.classAverage = Number((acumuladorGeneral / students.length).toFixed(2));
  console.log(claseNotas);
  console.log(claseNotas.students);

  return claseNotas;
}

Mi solución:
🚀
🚀
🚀
🚀
🚀
🚀
🚀

export function getStudentAverage(students) {
  const calcAverage = (list) => {
    console.log(list);
    return Number(
      (list.reduce((acc, item) => acc + item) / list.length).toFixed(2)
    );
  };

  return {
    classAverage: calcAverage(students.flatMap((e) => e.grades)),
    students: students.map((e) => ({
      name: e.name,
      average: calcAverage(e.grades),
    })),
  };
}
export function getStudentAverage(students) {
  // Tu código aquí 👈
  let studentsAverage = {
    classAverage: 0,
    students: []
  };

  students.forEach(student => {
    let average = student.grades.reduce((acum, sum) => acum + sum);
    average = average / student.grades.length;
    average = parseFloat(average.toFixed(2));
    studentsAverage.classAverage += average;
    studentsAverage.students.push({
      name: student.name,
      average: average
    });
  });
  studentsAverage.classAverage = studentsAverage.classAverage / students.length;
  studentsAverage.classAverage = parseFloat(studentsAverage.classAverage.toFixed(2));

  return studentsAverage;
}


.
.
.
.
.
.

export function getStudentAverage(students) {
  let finalAverages = {
    classAverage: 0,
    students: []
  }

  for (let student of students) {
    const finalGrade = student.grades.reduce((sum, grade) => sum + grade, 0) / student.grades.length;
    const person = {
      name: student.name,
      average: Number(finalGrade.toFixed(2))
    }
    finalAverages.students.push(person);
    finalAverages.classAverage += finalGrade;
  }
  finalAverages.classAverage = Number((finalAverages.classAverage / finalAverages.students.length).toFixed(2));

  return finalAverages;
}


console.log(getStudentAverage([
  {
      name: "Pedro",
      grades: [90, 87, 88, 90],
    },
    {
      name: "Jose",
      grades: [99, 71, 88, 96],
    },
    {
      name: "Maria",
      grades: [92, 81, 80, 96],
    }
]));

esta seria mi solución

export function getStudentAverage(students) {
  let initialvalue = 0;

  // //promedio de cada estudiante y promedio general
  const Students = students.map(student => {

    const sumaGrades = student.grades.reduce((acumulador, valorActual) => acumulador + valorActual, initialvalue);

    const promedioEstudiante = Number((sumaGrades / student.grades.length).toFixed(2));

    return { name: student.name, average: promedioEstudiante };
  });

  const sumaTotal = Students.reduce((acumulador, valorActual) => acumulador + valorActual.average, initialvalue);

  const promedioTotal = Number((sumaTotal / Students.length).toFixed(2));

  console.log(typeof promedioTotal);

  return { classAverage: promedioTotal, students: Students };
}

Comparto mi solución, lo realice con bucles

export function getStudentAverage(students) {
  const final = {
    classAverage: 0,
    students: []
  }
  let total = 0
  for (let i = 0; i < students.length; i++) {
    
    const classAverage = (students[i].grades.reduce((acum, value) => (acum + value)) / students[i].grades.length).toFixed(2)
    total += Number(classAverage)
    final.students.push({
      name: students[i].name,
      average: Number(classAverage)
    })
  }
  let totalFinal = (total / students.length).toFixed(2)
  final.classAverage = Number(totalFinal)
  return final;
  }

Esta es mi soluciopn, aunque me esta dando error con unos decimales, es decir, en class average en mi codigo me da 88.16 pero el espera 88.17, si tienen alguna idea de como puedo corregir eso?

function getStudentAverage(students) {
    let dataStudentsAverage = {
        classAverage: 0,
        students: []
        }
        students.forEach(student => {
            const sum = student.grades.reduce((acc, currentVal) => acc + currentVal)
            const average = Number((sum / student.grades.length).toFixed(2));
            const studentAverage = { name: student.name, average }
            dataStudentsAverage.students.push(studentAverage);
            dataStudentsAverage.classAverage += Number((average / students.length).toFixed(2));            
        });        
        return dataStudentsAverage
    }
export function getStudentAverage(students) {
  var obj = {
    classAverage: 0,
    students: []
  }
  students.forEach(function (student) {
    var objStudent = {
      name: student['name'],
      average: 0
    }
    var sum = student.grades.reduce((stu, value) => stu + value)
    var resultGrade = (sum / student['grades'].length).toFixed(2);
    objStudent.average = (Number(resultGrade));
    obj.classAverage += objStudent.average;
    obj.students.push(objStudent)
  })
  var result = (obj.classAverage / students.length).toFixed(2);
  obj.classAverage = (Number(result))
  return obj;
}

Mi solucion:
.
.
.
.
.
.
.
.
.
.
.
.
.
.

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let sumatoriaPromEstudiante = 0;

  let datosEstudiantes = [];

  students.forEach(estudiante => {
    let sumEstudiante = estudiante.grades.reduce((a, b) => (a + b));
    let promEstudiante = Number((sumEstudiante / estudiante.grades.length).toFixed(2));
    sumatoriaPromEstudiante += promEstudiante;
    datosEstudiantes.push({
      'name': estudiante.name,
      'average': promEstudiante
    });
  });

  let resultado = {
    'classAverage': Number((sumatoriaPromEstudiante / datosEstudiantes.length).toFixed(2)),
    'students': datosEstudiantes
  };

  return resultado;
}

// SPOILER SECTION
*
*
*
*
*
*
*
*
*
*
*
// SPOILER SECTION

Mi solución solo con lo visto hasta ahora y utilizando los métodos más basicos posibles.

function getStudentAverage(students) {
    let classAverage = 0
    let aveStudents = []

    for (let i = 0; i < students.length; i++) {
        let sumNotas = students[i].grades.reduce((acum, val) => {
            return acum + val
        }, 0)

        let promAlum = sumNotas / students[i].grades.length
        let promAlumForm = promAlum.toFixed(2)
        let promAlumDec = parseFloat(promAlumForm)

        aveStudents.push({ name: students[i].name, average: promAlumDec })
    }

        let sumPromAlum = aveStudents.reduce((acum, val) => {
            return acum + val.average
        }, 0)

        let promClass = sumPromAlum / aveStudents.length
        let sumPromAlumForm = promClass.toFixed(2)
        classAverage = parseFloat(sumPromAlumForm)

        return {
            classAverage: classAverage,
            students: aveStudents
        }
}
export function getStudentAverage(students) {
  let total_average = 0;
  let students_average = students.map(function (student) { 
    student.average = Number((student.grades.reduce((a, b) => (a + b)) / student.grades.length).toFixed(2));
    total_average += student.average;
    return {name: student.name, average: student.average};
  })

  let class_average = Number( (total_average / students_average.length).toFixed(2));
  
  let output = {
    "classAverage": class_average,
    "students": students_average
  }
  return output;
}

export function getStudentAverage(students) {
  // Dia 4 💚
  const output = {
    'classAverage': 0,
    'students': []
  }

  students.forEach(student => {
    let sum = student.grades.reduce((acumulador, nota) => acumulador + nota)
    let average = sum / student.grades.length
    output['students'].push({
      'name': student.name,
      'average': parseFloat(average.toFixed(2))
    })

    output['classAverage'] += average;
  })

  output['classAverage'] = parseFloat((output.classAverage / students.length).toFixed(2))
  return output
}

function getStudentAverage(students) {
  // Tu código aquí 
//funcion para sumar con reduce
const sum=(acum,grade) => {
        return acum+parseFloat(grade)
      }
//función para el promedio e indicar cantidad de decimales
const avg = (sumTotal,quantity, decimal=2)=>{
    return parseFloat((sumTotal/quantity).toFixed(decimal))
}
  let averages= students.map(student => { 
    return {
      name: student.name,
      average:avg(student.grades.reduce(sum, 0), student.grades.length)
    }
  })
    return {
        classAverage:avg(averages.map(ele=>ele.average).reduce(sum, 0) , averages.length),
        students:averages
    }
}

.








function getStudentAverage(students) {
  const newStudents = [];
  let totalAverage = 0;
  let sumTotalGrades = 0;
  let sumNumberOfGrades = 0;

  for (let student of students) {
    let averagePerStudent = 0;
    let gradesOfStudent = student.grades;
    let sumAllGradesPerStudent = 0;

    for (let grade of gradesOfStudent) {
      sumAllGradesPerStudent += grade;
    }
    averagePerStudent = Number((sumAllGradesPerStudent / gradesOfStudent.length).toFixed(2));
    newStudents.push({ name: student.name, average: averagePerStudent });
    sumTotalGrades += sumAllGradesPerStudent;
    sumNumberOfGrades += gradesOfStudent.length;
  }
  totalAverage = Number((sumTotalGrades / sumNumberOfGrades).toFixed(2));
  return { classAverage: totalAverage, students: newStudents }; 
 }

me tomo 2 dias resolver la mitad, pero nada como hacerlo un mismo

function getStudentAverage(students) {
  const studentAverage = [];
  
  for (let student of students) {
    let averageScoreStudent = student.grades.reduce((accumulator, grade) =>
      accumulator + grade, 0) / student.grades.length;

    let average = Number(averageScoreStudent.toFixed(2))
    studentAverage.push({name: student.name, average: average});
  }

  const total = studentAverage.reduce((total, b) => total + b.average, 0) / studentAverage.length;

  const finalAnswer = {
    classAverage: Number(total.toFixed(2)),
    students: studentAverage,
  }

  return finalAnswer
}

Mi solución, :3

export function getStudentAverage(students) {

  let allStudents = [];
  let classGrades = 0;

  students.forEach(student => {

    let currentGradesArray = student.grades;

    // we add the grades for the current student
    let studentGrades = currentGradesArray.reduce((acc, currentValue) => acc + currentValue);

    // we get the average for the current student
    let studentAvg = parseFloat((studentGrades / currentGradesArray.length).toFixed(2));

    // we buiild the student object
    let studentObj = {
      name: student.name,
      average: studentAvg
    };

    // we add the averages of each student and push the student object
    classGrades += studentAvg;
    allStudents.push(studentObj);
  });

  // finally we get the class average
  const classAvg = parseFloat((classGrades / students.length).toFixed(2));

  // we build the result object and return it
  const result = {
    classAverage: classAvg,
    students: allStudents
  };

  return result;
}

function getStudentAverage(students) {
  let salida = [];
  let sum = 0;
  for (let student in students) {
    let av = ((students[student].grades.reduce((t, n) => t + n) / students[student].grades.length).toFixed(2)) * 1;
    sum += av;
    salida.push({ name: students[student].name, average: av });
  }
return { classAverage: Number((sum / students.length).toFixed(2)), students: salida };
}

Pos ahí va mi aporte, con muchos días de retraso, lecturas de MDN y lugares random en Internet:

    // Tu código aquí 👈

    let averagedStudents = []; // En este arreglo ponemos los estudiantes y su promedio 
    let sumOfAverages=0; // Aquí la suma de los promedios, para después sacar el promedio general
    let output = {}; // Aquí voy a poner el resultado final, aunque no sé si output sea algún tipo de palabra reservada de javascript. Espero que no :s

    // Iteraremos para sacar el promedio de cada alumno
    for (const alumn of students) {
        let averagedAlumn = {}; // Aquí voy a guardar el estudiante en la iteración actual y su promedio como un objeto
        let avg = 0; // Para guardar el promedio del alumno

        // Voy a usar reduce para sumar todos los valores y luego sacar el promedio (a lo mejor se puede todo junto con otra función, pero lo desconozco)
        let sum = alumn.grades.reduce (function (acc, num) {
            return acc+num;
        },0);

        // Ahora si, sacamos el promedio
        avg = sum / alumn.grades.length;
        // Vamos a necesitar ir sumando los promedios para al final sacar el promedio general
        sumOfAverages += avg;

        // Ya tenemos todo lo que necesitamos, vamos a agregarlo al objeto averagedAlumn para después agregar ese objeto a mi arreglo de averagedStudents)
        averagedAlumn.name = alumn.name;
        averagedAlumn.average = parseFloat(avg.toFixed(2)); // Nos piden que sea número de 2 decimales, Internet dice que puedo usar parseFloat o el operador de "suma unaria" +
        averagedStudents.push(averagedAlumn); 
    }
    
    // Ahora, a mi objeto de salida 
    output.classAverage = parseFloat(((sumOfAverages/students.length).toFixed(2))) // Me parece increíble que en javascript se pueda esto
    output.students = averagedStudents;

    // Retornamos el objeto de salida
    return output;

De seguro no es la mejor manera, pero funciona

export function getStudentAverage(students) {
    const ClassNotes = {
        students: [],
        classAverage: 0
    };
    for (const student of students) {
        const nombreEstudiante = student.name,
            notasEstudiante = student.grades;
        let tpm = 0, nota = 0;
        for (nota of notasEstudiante) { nota = nota + tpm; tpm = nota; };
        nota = nota / student.grades.length;
        ClassNotes.students.push({ name: nombreEstudiante, average: Number(nota.toFixed(2)), });
    };
    let promedioTotal = 0, tpm = 0;
    for (let i = 0; i < ClassNotes.students.length; i++) { 
        let nota = ClassNotes.students[i].average; 
        promedioTotal = nota + tpm; tpm = promedioTotal; 
    }
    ClassNotes.classAverage =  Number ((promedioTotal / ClassNotes.students.length).toFixed(2));

    return ClassNotes;
}; 

Esta es mi solucion

const resultStudents ={
        classAverage: 0,
        students:[]
    }
    students.map(student=>{

        let promedioEstudiante=student.grades.reduce((anterior,actual)=>{
            return anterior+actual
        },0)

        promedioEstudiante=promedioEstudiante/student.grades.length
        
        resultStudents.students.push({
            name:student.name,
            average:parseFloat(promedioEstudiante.toFixed(2))
        })
        
        resultStudents.classAverage=resultStudents.classAverage+promedioEstudiante
    })
    resultStudents.classAverage=parseFloat(((resultStudents.classAverage)/resultStudents.students.length).toFixed(2))

    return resultStudents

MI SOLUCIÓN
MI SOLUCIÓN
MI SOLUCIÓN
.
.
.
.
.
Utilizando los métodos map y reduce.

export function getStudentAverage(students) {
    const amountStudents = students.length;
	  let sumGradesAverage = 0;
	
	  const studentsAverages = students.map(student => {
	    const amount = student.grades.length;
	    const averageGrades = student.grades.reduce((acum, num) => acum + num) / amount;
	    sumGradesAverage += averageGrades;
	    return { name: student.name, average: parseFloat(averageGrades.toFixed(2)) };
	  });
	  const totalAverage = parseFloat((sumGradesAverage / amountStudents).toFixed(2));
	
	  return { classAverage: totalAverage, students: studentsAverages };
}
export function getStudentAverage(students) {
  // Tu código aquí 👈
  let classSum = 0;
  let newStudents = [];
  let studentsAverage = students.map(function(student) {
    let sum = 0;
    student.grades.forEach(function (grade) {
      sum += grade;
    });
    let average = sum / student.grades.length;
    const newStudent = {
      name: student.name,
      average: Number(average.toFixed(2)),
    };
    classSum += newStudent.average;
    return newStudent;
  });

  let classAverage = classSum / studentsAverage.length;
  newStudents = {
    classAverage: Number(classAverage.toFixed(2)),
    students: studentsAverage
  }
  console.log(newStudents);
  return newStudents

}

Mi solución:

function getStudentAverage(students) {
  const averages = {
    classAverage: null,
    students: []
  }
  students.forEach(student => {
    averages.students.push({
      name: student.name,
      average: Number((student.grades.reduce((a, b) => a + b) / student.grades.length).toFixed(2))
    })
  })
  averages.students.forEach(student => averages.classAverage += student.average);
  averages.classAverage = Number((averages.classAverage / averages.students.length).toFixed(2));
  return averages;
}

Mi solución 🤓
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

const getAverage = (values, length) => {
  const sum = values.reduce((a, b) => a + b);
  const avg = (sum / length).toFixed(2);

  return parseFloat(avg);
};

const getStudentAverage = (students) => {
  const solutionAverage = {};
  const notesStudents = [];
  const totalStudents = students.length;

  const studentsAverage = students.map((element) => {
    const studentAverage = getAverage(element.grades, element.grades.length);

    return {
      name: element.name,
      average: studentAverage,
    };
  });

  studentsAverage.map((element) => notesStudents.push(element.average));

  const classAverageSolution = getAverage(notesStudents, totalStudents);

  solutionAverage["classAverage"] = classAverageSolution;
  solutionAverage["students"] = studentsAverage;

  return solutionAverage;
};

Reduce llamando a otro reduce, just awesome! 😃

 function getStudentAverage(students) {
  // Tu código aquí 👈
  const ave = students.reduce((acc, current) => {
    console.log("🚀 ~ acc ", acc);
    let avecurrent = current.grades.reduce((acc, current) => {

      return acc + current;
    }, 0);


    return {
      ...acc,
      classAverage: (acc.classAverage + (avecurrent / current.grades.length)),
      students: [
        ...acc.students,
        {
          name: current.name,
          average: Number((avecurrent / current.grades.length).toFixed(2)),
        }]

    }
  }, { classAverage: 0, students: [] });

  return {
    ...ave,
    classAverage: Number((ave.classAverage / students.length).toFixed(2)),
  }
};

export function getStudentAverage(students) { 
  const average = {
    classAverage: 0,
    students: [],
  };

  const u = students.map((e) => {
    const promedioDecimal = e.grades.reduce((a, b) => a + b) / e.grades.length;
    const promedio = parseFloat(promedioDecimal.toFixed(2));
    average.students.push({ name: e.name, average: promedio });
    return promedioDecimal;
  });

  const promedioGrupoDecimal = u.reduce((va, nv) => va + nv) / students.length
  const promedioGrupo = Number(promedioGrupoDecimal.toFixed(2));
  average.classAverage = promedioGrupo;

  return average;
}

Estimada comunidad, aquí les comparto mi solución desde luego que puede ser optimizada.

Saludos Cordiales

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let sumaNotasClase = 0;
  let studentAverage = 0;
  let studentVector = [];
  let classAverage = 0;

  for (let i = 0; i < students.length; i++) {
    studentAverage = (students[i].grades.reduce(function (acumulado, nota) {
      return acumulado + nota;
    }, 0)) / students[i].grades.length;
    sumaNotasClase = sumaNotasClase + studentAverage;
  }

  classAverage = parseFloat((sumaNotasClase / students.length).toFixed(2));

  studentVector = students.map(function (student) {
    return {
      name: student.name,
      average: parseFloat(((student.grades.reduce(function (acumulado, nota) {
        return acumulado + nota;
      }, 0)) / student.grades.length).toFixed(2))
    };
  });

  let respuesta = {
    classAverage: classAverage,
    students: studentVector
  }

  return respuesta;
}

My solution

let result = {
                classAverage: 0,
                students: [],
            }


            for (let i = 0; i <= students.length - 1; i++) {
             
                let students1 = { name: 0, grades: 0 };

                let sumaNotas = students[i].grades.reduce(
                    (acum, currentVal) => acum + currentVal,
                    0
                );
                // console.log(students.length)
                //console.log(promedioI)

                let promedioI = parseInt(((sumaNotas / students[i].grades.length).toFixed(1)));

                students1.grades=promedioI;
                students1.name = students[i].name;

                result.students.push(students1);
               // console.log(promedioI)

            }
            let promedioGeneral=0;
            for(let j=0;j<=result.students.length -1;j++){
                
                promedioGeneral += result.students[j].grades;

                result.classAverage=parseInt((promedioGeneral/result.students.length).toFixed(1));
               // console.log(promedioGeneral);
            }


            return result;

Solución

function getStudentAverage(students) {
  // Tu código aquí 👈
  const group = {
  	classAverage: 0,
    students: []
  }
  
 	for (let student of students) {
  
    let studentSum = student.grades.reduce((acc, cur) => acc+cur, 0)
    let studentAverage = studentSum / student.grades.length
    studentAverage = Number.parseFloat(studentAverage.toFixed(2))
    group.classAverage += studentAverage
    group.students.push({name: student.name, average: studentAverage})
  }
 
 	group.classAverage = Number
  	.parseFloat((group.classAverage / group.students.length).toFixed(2))
  
 	console.log(group)
}

Mi solución sería:
.
.
.
.
.
.
.
.
.
.

<script>
function getStudentAverage(students) {
  let averages = students.map((student) => {
    return {
      name: student.name,
      average:
        Math.round(
          student.grades.reduce(
            (average, grade) => (average += grade / student.grades.length),
            0
          ) * 100
        ) / 100,
    };
  });
  return {
    classAverage:
      Math.round(
        averages.reduce(
          (total, student) => (total += student.average / averages.length),
          0
        ) * 100
      ) / 100,
    students: averages,
  };
}
</script>

Mi Solución

export function getStudentAverage(students) {
  const studentsAverage = students.map(student => ({ name: student.name, average: +(student.grades.reduce((acc, cur) => acc + cur, 0) / student.grades.length).toFixed(2) }))

  const classAverage = +(studentsAverage.reduce((acc, cur) => acc + cur.average, 0) / studentsAverage.length).toFixed(2)

  return {classAverage, students: studentsAverage}
}
const average = (quantity, div) => Math.round(quantity / div * 100) / 100;

export const getStudentAverage = (students) => {
  let classAverage = 0;
  for (let i = 0; i < students.length; i++) {
    students[i].average = students[i].grades.reduce((acc, curr) => acc + curr, 0);
    students[i].average = average(students[i].average, students[i].grades.length);
    delete students[i].grades;

    classAverage += students[i].average;
  }
  classAverage = average(classAverage, students.length);
  return { classAverage, students }
}
export function getStudentAverage(students) {
  // Tu código aquí 👈
  let averageGrads = {};
  averageGrads.students = [];
  let totalAvgPoints = 0;

  for (let student of students) {
    let avgStudent = student.grades.reduce((a, b) => a + b) / student.grades.length;
    averageGrads.students.push({ name: student.name, average: Number(avgStudent.toFixed(2)) });
    totalAvgPoints += avgStudent;
  }

  let classAverage = totalAvgPoints / students.length;
  classAverage = Number(classAverage.toFixed(2));
  averageGrads = { classAverage: classAverage, ...averageGrads };

  return averageGrads;
}

Estimados comparto esta info que me ayudo a entender mejor una excelente herramienta https://www.freecodecamp.org/espanol/news/javascript-map-como-utilizar-la-funcion-js-map-metodo-de-arreglo/

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let grados = []
  let names = []
  let studentChange = []
  grados.push(students.map(element => element.grades))
  names.push(students.map(element => element.name))
  let aver = []
  for (let i = 0; i < grados[0].length; i++) {
    aver.push(Number((grados[0][i].reduce((partialSum, a) => (partialSum + a), 0) / grados[0][i].length).toFixed(2)))
    studentChange.push({
      name: names[0][i],
      average: aver[i]
    })

  }
  let promedio = (Number((aver.reduce((partialSum, a) => (partialSum + a), 0) / aver.length).toFixed(2)))

  return ({
    classAverage: promedio,
    students: studentChange
  })
}

comparto mi código

export function getStudentAverage(students) {
    /* Creamos un array donde obtendremos los estudiantes con su promedio, pero me apoyo de 
    los mapas para
    Obtengo el total de la suma de todas las calificaciones de cada alumnp
    */
    const estudiantesConPromedio = students.map((student) => {
        //paso el valor de la calificacion de cada estudiante a una variable para poder leer individualmente
        //lo puse en un arreglo llamado grades
        const califAlumno = student.grades;
        //ahora calculo el promedio de todas las calificaciones y las divido entre el tamaño del arreglo grades
        const promAlumno = califAlumno.reduce((sumaPromedios, item) => sumaPromedios + item, 0) / califAlumno.length;
        //ahora retorno un objeto con el valor de las calificaciones
        return { //primeramente paso el valor del nombre tomando el array que me llega
            name: student.name,
            //ahora guardo su promedio truncando a dos decimales
            average: Number(promAlumno.toFixed(2)),
        };
    });
    //ahora obtengo el promedio general, sumando todos los promedios y los divido entre el total de registros
    const classAverage = estudiantesConPromedio.reduce((total, student) => total + student.average, 0) / estudiantesConPromedio.length;
    //convierto el promedio de la clase a dos decimales
    const califFinales = {
        classAverage: Number(classAverage.toFixed(2)),
        students: estudiantesConPromedio,
    };
    //retorno el objeto que tiene los alumnos y sus promedios
    return califFinales;
}

.
.
.

.
.
.
.
.
.
.
.
.

export function getStudentAverage(students) {
  // Tu código aquí 👈
  const studentsAverages = [];
  students.forEach(
    (student) => {
      const gradesArr = student.grades;
      let gradesAVG = gradesArr.reduce(function (sum, value) {
        return sum + value;
      }, 0) / gradesArr.length;
      gradesAVG = Number(gradesAVG.toFixed(2));
      studentsAverages.push(
        {
          name:     student.name,
          average:  gradesAVG
        }
      );
    }
  );
  let classAverage = studentsAverages.reduce(function (sum, student) {
    return sum + student.average;
  }, 0) / studentsAverages.length;
  classAverage = Number(classAverage.toFixed(2));
  return {
    classAverage: classAverage,
    students:     studentsAverages
  }
}

Me encantan los playgrounds hagan más que solo 30 días please.

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let meanStudents = {};
  let prom = 0
  let studentsList = [];
  // Object logical construct
  for (let student of students) {
    let promPerStudent = student.grades.reduce((value, value2) => value + value2) / student.grades.length;
    studentsList.push({ name: student.name, average: Number(promPerStudent.toFixed(2)) });
    prom += promPerStudent;
  }
  // add to Object classAverage and studentsList properties
  prom = (prom / students.length).toFixed(2);
  meanStudents["classAverage"] = Number(prom);
  meanStudents["students"] = studentsList;
  return meanStudents;
}

Les comparto mi solución:

pero antes:

Gente mi solucion
.
.
.
.
.
.
.
.
.

.
.

export function getStudentAverage(students) {
  // Tu código aquí 👈
  
  let resultAvg = students.map(function (student) {
    return {
      name: student.name,
      average: Number(((student.grades.reduce((a, b) => a + b, 0)) / student.grades.length).toFixed(2))
    }
  });
  let suma = 0;
  resultAvg.forEach(function (stu) { 
    suma += stu.average;
  });
  return {
    classAverage: Number((suma / resultAvg.length).toFixed(2)),
    students: resultAvg
  };
}

.
.
.
.
.
.
.

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let response = {
    classAverage: 0,
    students: []

  };
  response.students = students.map(
    student => {
      let avg = Number.parseFloat((student.grades.reduce((a, b) => a + b) / student.grades.length).toFixed(2));
      response.classAverage += avg;
      return {
        name: student.name, average: avg
      }
    });


  response.classAverage /= response.students.length;
  response.classAverage = Number.parseFloat(response.classAverage.toFixed(2))
  return response;  
}

Listo, esta es mi solución

.
.
.
.
.
.
.
.
.
.
.
.

export function getStudentAverage(students) {
  let averages = { classAverage: 0, students: [] };
  students.forEach((student) => {
    let average =
      student.grades.reduce(function (average, qualification, index) {
        return average + qualification;
      }) / student.grades.length;
    averages.students.push({
      name: student.name,
      average: parseFloat(average.toFixed(2))
    });
    averages.classAverage += average;
  });

  averages.classAverage = parseFloat((averages.classAverage / students.length).toFixed(2));

  return averages;
}

Cordial saludo socializo mi solución ante el ejercicio. Muchas gracias.

function getStudentAverage(students) {
  let average;

  let averageStudents = {
    classAverage: 0,
    students: [],
  };

  //calcular promedio de cada estudiante.
  for (const student of students) {
    let total = student.grades.reduce((accumulator, grades) => {
      return accumulator + grades;
    }, 0);

    average = total / 4;

    //suma promedio de cada estudiante
    averageStudents.classAverage += average;

    //registro estudiantes arreglo estudiantes objeto -> averageStudents
    averageStudents.students.push({ name: student.name, average: average });
  }

  //calculo promedio total de la clase
  averageStudents.classAverage /= students.length;

  //console.log(averageStudents.classAverage.toFixed(2));

  // impresion resultados

  console.log(`classAverage: ${averageStudents.classAverage.toFixed(2)}`);
  for (const student of averageStudents.students) {
    console.log(student);
  }
}

getStudentAverage(students = [
    {
      name: "Pedro",
      grades: [90, 87, 88, 90],
    },
    {
      name: "Jose",
      grades: [99, 71, 88, 96],
    },
    {
      name: "Maria",
      grades: [92, 81, 80, 96],
    },
  ]
);

export function getStudentAverage(students) {
  var gradesClass = {
    classAverage: 0,
    students: []
  }

  let averageTotal = 0;  
  for (let student of students) {
    let average = Number((student.grades.reduce(function (acumulate, grade) {
      return acumulate + grade
    }) / student.grades.length).toFixed(2)); 

    averageTotal = averageTotal + average;

    gradesClass.students.push({ name: student.name, average: average });
  }

  gradesClass.classAverage = Number((averageTotal/students.length).toFixed(2));

  return gradesClass;
}
export function getStudentAverage(students) {
  // Tu código aquí 👈
  const studentsWithAverage = students.map((student) => {
    const sumGrades = student.grades.reduce((average, currentValue) => average + currentValue, 0);
    const average = sumGrades / student.grades.length;

    return {
      name: student.name,
      average: Number(average.toFixed(2)),
    }
  });

  const sumAverages = studentsWithAverage.reduce((average, currentStudent) => average + currentStudent.average, 0);
  const classAverage = sumAverages / studentsWithAverage.length;

  return {
    classAverage: Number(classAverage.toFixed(2)),
    students: studentsWithAverage
  }
}
export function getStudentAverage(students) {

  let student = students.map((elemet) => {
    return {
      name: elemet.name,
      average: Number(((elemet.grades.reduce((a, b) => a + b)) / elemet.grades.length).toFixed(2))
    }
  })

  let classAverageArray = student.map((elemet) => elemet.average).reduce((a,b)=> a + b) 
  let classAverageMat = Number((classAverageArray / student.length).toFixed(2))

 
  const obj = {
    classAverage: classAverageMat,
    students: student
  }

 
  return obj
}

Hola. Mi solución comentada
.
.
.
.
.
.
.
.
.
.
.

export function getStudentAverage(students) {
  /* objeto de acumulación*/
  let ans = { classAverage: 0, students: [] }
  /* recorrido sobre arreglo*/
  students.forEach(s => {
    /* obtención de nombre */
    let name = s.name
    /* obtención de avr haciendo suma con reduce y dividiento entre el total de valores en el arreglo */
    let avr = s.grades.reduce((a, b) => a + b) / s.grades.length
    /* acumulación de avr con un promedio fraccionado */
    ans.classAverage += avr / students.length
    /* adición de data al array2 con truncamiento de decimales */
    ans.students.push({ name:name, average: parseFloat(avr.toFixed(2)) })
  })
  /* truncamiento de decimales al atributo cA */
  ans.classAverage = parseFloat(ans.classAverage.toFixed(2))
  /* return */
  return ans
}

++
+
+
+
+
+
+
+
+

export function getStudentAverage(students) {
    let promedio={
        classAverage:0,
        students:[]
    }
    let promedios=[];
    for(const [key, value] of Object.entries(students)){
        let prom= parseFloat((value.grades.reduce((acc, item) => {
          return acc = acc + item;
        })/value.grades.length).toFixed(2));
        promedios.push(prom)
        let objeto = {
          name:value.name,
          average:prom
        };
        promedio.students.push(objeto);
      }
    promedio.classAverage=parseFloat((promedios.reduce((acc, item) => {
      return acc = acc + item;}) / promedios.length).toFixed(2));
    return promedio; 
}

Por aquí dejo mi aporte:

export function getStudentAverage(students) {
  // Tu código aquí 👈
  // Tu código aquí 👈
  let promGral = 0;
  let lngGral = students.length;
  for (let i = 0; i < students.length; i++) {
    let promStudent = students[i].grades.reduce(function (a, b) {
      return a + b;
    }, 0);
    let lngGrade = students[i].grades.length;
    let total = promStudent / lngGrade
    students[i].grades = parseFloat(total.toFixed(2));
    promGral += students[i].grades;
  }

  promGral = promGral / lngGral;
  let newArr = students.map(({ grades, name }) => ({
    average: grades,
    name: name
  }))
  const result = {
    classAverage: parseFloat(promGral.toFixed(2)),
    students: newArr
  }

  return result;
}

Mi solución 🤯:

export function getStudentAverage(students) {
  const studentsResult = students.reduce(
    (_prev, _current) => {
      const average = (
        _current.grades.reduce((prev, curr) => prev + curr, 0) / _current.grades.length
      ).toFixed(2);

      return {
        classGrade: Number(_prev.classGrade) + Number(average),
        students: [
          ..._prev.students,
          {
            name: _current.name,
            average: Number(average),
          },
        ],
      };
    },
    {
      classGrade: 0,
      students: [],
    }
  );

  const averageClass = (studentsResult.classGrade / students.length).toFixed(2);

  return {
    classAverage: Number(averageClass),
    students: studentsResult.students,
  };
}

🛡️Sin spoilers🛡️
Mi solución: con un forEach y un reduce.

export function getStudentAverage(students) {
  let studentsResponse = [];
  let classAverage = 0;


  students.forEach((student) => {
    const average = student.grades.reduce((a, b) => a + b, 0) / student.grades.length;

    const studentResponse = {
      name: student.name,
      average: Number(average.toFixed(2)),
    }

    classAverage += average;
    studentsResponse.push(studentResponse);
  });

  classAverage = classAverage / students.length;
  classAverage = Number(classAverage.toFixed(2));

  return {
    classAverage,
    students: studentsResponse,
  };
} 

Esta es mi solución
+
+
+
+
+
+
+
+

function getStudentAverage(students) {

    const averageStudents = students.map(item => 
        {
            return {
                name: item.name,
                average: parseFloat(((item.grades.reduce((a,c)=>  a + c, 0)) / item.grades.length).toFixed(2))
            }
      
    });

         
        return {
            classAverage: parseFloat(((averageStudents.reduce((a, c) =>  a + c.average, 0 )) / averageStudents.length).toFixed(2)),
            students: [...averageStudents]
        };

  };

Mi solución:

export function getStudentAverage(students) {
  let classAverage = 0
  let studentsAverage = []

  for (let i = 0; i < students.length; i++) {
    let average = 0
    for (let grade of students[i].grades) {
      average += grade / students[i].grades.length
    }
    let student = {
      name: students[i].name,
      average: Number(average.toFixed(2))
    }
    studentsAverage.push(student)
    classAverage += average / students.length
  }
  let averages = {
    classAverage: Number(classAverage.toFixed(2)),
    students: studentsAverage
  }
  return averages
}


.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

export function getStudentAverage(students) {
  var sumaclase = 0

  let resultado = {
    classAverage: 0,
    students: []
  }

  for ( let estudiante of students) {
      
      let arreglo = {
        name: estudiante.name,
        average: 0
      }

      let calculo = (estudiante.grades.reduce((accumulator, currentValue) => accumulator + currentValue, 0)) / estudiante.grades.length

      let promedio = parseFloat(calculo.toFixed(2));
      arreglo.average = promedio;
    resultado.students.push(arreglo);

      sumaclase+= promedio
      
  }

  let calculopromediogeneral = sumaclase / resultado.students.length

  resultado.classAverage = parseFloat(calculopromediogeneral.toFixed(2))

  return (resultado)
   
 }

.
.
.
.
.
.
.
.
.
.
.
.
.

  function getStudentAverage(students) {
    let studentsProm = []
    let sumaTotal = 0

    // Recorremos cada estudiante reducir el arreglo y retornar el promedio
    students.forEach(element => {
        let prom = element.grades.reduce(function(acum, num) {
            return acum + num
        }, 0)/element.grades.length

        sumaTotal += prom

        studentsProm.push({'name': element.name, 'average': prom})
    })
    let salida = {'classAverage': 0, 'students': studentsProm}
    salida.classAverage = (sumaTotal / students.length).toFixed(2)

    //console.log(salida);
    return salida
  }

Solución… 😄
.
No es la solución más optima… para nada 😂. Pero a modo de practicar arrays y sus métodos.
.

export function getStudentAverage(students) {
  //Array de estudiantes con promedio
  let studentsWA = [];

  //Creamos nuevos estudiantes con promedio
  let averages = students.map((average) => {
    let n = average.grades.length; //Cantidad de notas
    //Acumulamos las notas para cada estudiante
    let avrs = average.grades.reduce((acc, avr) => {
      return acc + avr;
    }, 0);

    let newStudentWA = {
      name: average.name,
      average: Number((avrs / n).toFixed(2))
    };

    //Añadimos al array de estudiantes con promedio 
    studentsWA.push(newStudentWA);
  });

  //cantidad de estudiantes
  let nStudents = studentsWA.length;

  //Acumulamos las notas de todos los estudiantes
  let classAverage = [...studentsWA].reduce((acc, avr) => {
    return acc + avr.average;
  }, 0);

  /* Creamos el objeto resultado con el promedio
   de todos los estudiantes y los estudiantes con promedio */
  let result = {
    classAverage: Number((classAverage / nStudents).toFixed(2)),
    students: studentsWA
  };

  //Retornamos el resultado
  return result;
}

Mi humilde solución solo usando lo aprendido, sin nada que no hemos visto.

export function getStudentAverage(students) {
  var promedio = 0;
  var promediogrupal = 0;
  var suma = 0;
  var personalaverage = [];
  for (const prop in students) {
    suma = 0;
    for (const element of students[prop].grades) { suma += element; }
    promedio = suma / students[prop].grades.length;
    promediogrupal += promedio;
    personalaverage.push({ name: students[prop].name, average: Number(promedio = promedio.toFixed(2)) });
  }
  promediogrupal /= students.length;
  return { classAverage: Number(promediogrupal.toFixed(2)), students: personalaverage };
}

Mi solu

export function getStudentAverage(students) {
  const averages = {
    classAverage: 0,
    students: []
  }
  let gradesRegister = []

  for (let currentStudent in students) {
    let student = students[currentStudent]
    let averageGrade = student.grades.reduce((a, b) => a + b, 0) / student.grades.length
    averages.students.push({ 'name': student.name, 'average': Number(averageGrade.toFixed(2)) })
    gradesRegister.push(student.grades)
  }
  const classAverage = gradesRegister.flat().reduce((a, b) => a + b, 0) / gradesRegister.flat().length
  averages.classAverage = Number(classAverage.toFixed(2))
  return averages 
}

Spoilers:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mi solución:

export function getStudentAverage(students) {
  const result = {
    classAverage: 0,
    students: []
  }
  for (let student of students) {
    let average = 0;
    for (let grade of student.grades) {
      average = average + grade;
    }
    average = average / student.grades.length;
    average = Number(average.toFixed(2));
    result.students.push({ name: student.name, average: average });
  }

  let classAverage = 0;
  for (let student of result.students) {
    classAverage = classAverage + student.average;
  }
  classAverage = classAverage / result.students.length;
  classAverage = Number(classAverage.toFixed(2));
  result.classAverage = classAverage;
  return result;
}

Buenas comparto mi solucion
*
*
*
*
*
*
*
*
*

function getStudentAverage(students) {
  const newStudents = students.map((student) => {
    let totalGrades = student.grades.reduce((acum, grade) => acum + grade, 0)
    let average = Number((totalGrades / student.grades.length).toFixed(2))

    return {
      name: student.name,
      average
    }
  })

  const totalGrades = newStudents.reduce((acum, student) => acum + student.average, 0)
  const classAverage = Number((totalGrades / students.length).toFixed(2))

  return {
    classAverage,
    students: newStudents
  }
}
export function getStudentAverage(students) {
  let new_obj = {}
  let promedio_general = 0
  let estudiantes= []

  students.forEach((student) => {
    let promedio_estudiante = (student.grades.reduce((a, b) => a + b)) / student.grades.length
    promedio_general += promedio_estudiante / students.length
    estudiantes.push({ name: student.name, average: parseFloat(promedio_estudiante.toFixed(2)) })
  })
  new_obj['classAverage'] = parseFloat(promedio_general.toFixed(2))
  new_obj['students'] = estudiantes
  return new_obj
}

Hasta que lo resolvi, casi todo el dia pero lo hice:
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let sumAverageClass = 0;
  const averClass = [];
  for (const student in students) {
    const sumAverage = students[student].grades.reduce((grade, sum) => (grade + sum));
    sumAverageClass += (sumAverage / students[student].grades.length);
    averClass.push({ name: students[student].name, average: Number((sumAverage / students[student].grades.length).toFixed(2)) });
  }
  return { classAverage: Number((sumAverageClass / averClass.length).toFixed(2)), students: averClass };
}

Les comparto mi solución al reto:

function getClassAverage(students) {

  //Esta funcion interna calcula el promedio de cada estudiante y se devuleve un array de objetos con el
  //nombre y promedio de cada estudiante
  const getStudentAverage = (students) => {
    const studentAverage = [];
  
    for (let student of students) {
      const draftAverage = student.grades.reduce((acc, sum) => acc + sum, 0)/student.grades.length;
      const average = Number.parseFloat(draftAverage.toFixed(2));
      studentAverage.push({'name': student.name, 'average': average});
    }
    
    return studentAverage;
  }

  //Aqui sumamos cada promedio individual y despues sacamos el promedio general de la clase
  let classAverage = 0;
  const studentData = getStudentAverage(students);
  for(let student of studentData) {
    classAverage += student.average;
  }
  classAverage = classAverage/studentData.length;
  const generalAverage = Number.parseFloat(classAverage.toFixed(2));

  console.log(typeof generalAverage)

  //Devolvemos un objeto con el promedio general de la clase y con un array que tiene en objetos los datos
  //nombre y promedio de cada estudiante
  return {
    'classAverage': generalAverage,
    'students': studentData,
  }
}

Comparto mi solución

const sumValues = (accum, value) => accum + value;
const getAverage = (arr) => parseFloat((arr.reduce(sumValues, 0) / arr.length).toFixed(2));

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let classAverage = 0;

  const average = students.map((student) => {
    const studentAv = getAverage(student.grades);
    classAverage += studentAv / students.length;
    return {
      name: student.name,
      average: studentAv
    }
  }
  );
  
  return {
    classAverage: parseFloat(classAverage.toFixed(2)),
    students: average 
  }
  
}

🛡️Escudo anti spoilers🛡️
🛡️ Aquí mi solución al playground:
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️
🛡️

export function getStudentAverage(students) {
  let res = {
    classAverage: 0,
    students: []
  }

  students.forEach(s => {
    let average = 0;
    average = s.grades.reduce((acc, g) => acc + g, 0) / s.grades.length;
    average = Number(average.toFixed(2))
    res.students.push({ name: s.name, average })
    res.classAverage += average
  });
  res.classAverage = res.classAverage / res.students.length;
  res.classAverage = Number(res.classAverage.toFixed(2))
  return res
}

Lo logre 😋

export function getStudentAverage(students) {
  let objeto = {
    classAverage: 0,
    students : []
  };
  let promedios = [];
  const promedio = (array) => parseFloat((array.reduce((a, b) => a + b, 0) / array.length).toFixed(2));

  for (let student of students) {
    promedios.push(promedio(student.grades));
    objeto.students.push({ name: student.name, average: promedio(student.grades)});
  }
  objeto.classAverage = promedio(promedios);

  return objeto;

}

Mi solución compañeros, tambien se puede user parseFloat para transforma un string a un numero de punto flotante.

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let total = 0;

  const response = students.map(item => {
    const sum = item.grades.reduce((ac, current) => (ac + current), 0);


    const average = sum / item.grades.length
    total += average;

    return {
      name: item.name,
      average: parseFloat(average.toFixed(2))
    }
  })

  const classAverage = total / students.length;

  return {
    classAverage: parseFloat(classAverage.toFixed(2)),
    students: response
  }
}

Muchos errores de tipeo tuve!!! ya voy a ir mejorando eso con la práctica. Acá va mi solución
.
.
.
.
.
.
.
.
.

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let accumulateGrades = 0;
  let classAverage;
  let studentsx = [];
  students.forEach(student => {
    let studentAverage = student.grades.reduce((acc, valor) => acc + valor, 0) / student.grades.length;
    studentsx.push({ name: student.name, average: Number(studentAverage.toFixed(2))})
  })
  studentsx.forEach(student => {
    accumulateGrades += student.average;
  })
  classAverage = parseFloat((accumulateGrades / studentsx.length).toFixed(2))
  return {classAverage: classAverage, students: studentsx}
}

Esta es mi Sulucion… Saludos

export function getStudentAverage(students) {
  let result = {
    classAverage: 0,
    students: [],
  }
  result.classAverage = Number(((students.map(x => (x.grades.reduce((a, b) => a + b, 0)) / x.grades.length).reduce((a, b) => a + b,)) / students.length).toFixed(2));

  for (let index = 0; index < students.length; index++) {

    result.students.push({ name: students[index].name, average: Number((students[index].grades.reduce((a, b) => a + b, 0) / students[index].grades.length).toFixed(2)) });
  }
  return result;
}

Después del desafío anterior, pude resolver este con un poco menos de dificultad:

export function getStudentAverage(students) {
// declaramos el objeto a retornar
  const averageData = {
    classAverage: 0,
    students: [],
  }
// declaramos una variable para guardar el promedio total de la clase
  let totalAverage = 0;
// iteramos dentro del array 'students' para sacar el dato de las notas por estudiante
  for (let i = 0; i < students.length; i++) {
// declaramos una variable para guardar la suma de las notas por cada estudiante
    let suma = 0;
// iteramos dentro del array ''grades' para sumar cada nota
    for (let j = 0; j < students[i].grades.length; j++) {
// en cada iteración, se suma cada elemento dentro de 'grades' y se guarda en 'suma'
      suma += students[i].grades[j];
    }
// calculamos el promedio de notas de cada estudiante y lo guardamos en 'averageStudent'
    let averageStudent = Math.round((suma / students[i].grades.length) * 100) / 100;
// en cada iteración del primer ciclo, acumulamos el valor de 'averageStudent' para calcular el promedio de la clase
    totalAverage += averageStudent
// agregamos el nombre y promedio de cada estudiante a nuestro objeto 'averageData'
    averageData.students.push(
      {
        name: students[i].name,
        average: averageStudent,
      }
    );
  }
// calculamos el promedio total de la clase y lo guardamos dentro del objeto 'averageData'
  averageData.classAverage = Math.round((totalAverage / averageData.students.length) * 100) / 100
// retornamos nuestro objeto con la información solicitada
  return averageData;
} 

Para resolver este desafío, necesitamos calcular el promedio de cada estudiante y el promedio general de la clase. Primero, podemos recorrer el array de estudiantes con un bucle for para calcular el promedio de cada uno. Para ello, podemos utilizar el método reduce para sumar todas las notas de cada estudiante y después dividir el resultado entre la cantidad de notas que tiene cada estudiante.

Una vez que tenemos el promedio de cada estudiante, podemos sumar todos los promedios y dividirlos por la cantidad de estudiantes para obtener el promedio general de la clase.

Finalmente, creamos un objeto con las propiedades classAverage y students, donde classAverage tendrá el valor del promedio general de la clase y students será un array con los nombres de los estudiantes y sus respectivos promedios.

Aquí está el código para resolver el desafío:

export function getStudentAverage(students) {
  let classTotal = 0;
  let studentsData = [];

  for (let i = 0; i < students.length; i++) {
    const student = students[i];
    const average = student.grades.reduce((acc, curr) => acc + curr) / student.grades.length;
    studentsData.push({ name: student.name, average: Number(average.toFixed(2)) });
    classTotal += average;
  }

  const classAverage = Number((classTotal / students.length).toFixed(2));

  return { classAverage, students: studentsData };
}

Solución humilde como el bicho:

S
I
U
U
U
U
U
U
U
U
U
U

export function getStudentAverage(students) {
  let classAverage
  let sumAverage = 0
  let studentsAverage = students.map(student => {
      let average = student.grades.reduce((currentNote, nextNote) =>(currentNote + nextNote), 0) / student.grades.length
      average = +average.toFixed(2)
      sumAverage += average
      return {
          name: student.name,
          average
      }
  })
  classAverage = +(sumAverage / students.length).toFixed(2) 
  return {
      classAverage,
      students: studentsAverage
  }
}

Solución

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let averages = {
    classAverage: 0,
    students: []
  }
  let totalAverageStudents = 0;
  students.forEach(function (student) {
    let totalStudent = student.grades.reduce((a, b) => a + b);
    let averageStudent = Number((totalStudent / student.grades.length).toFixed(2));
    averages.students.push({
      name: student.name,
      average: averageStudent
    });

    totalAverageStudents += averageStudent;
  })

  averages.classAverage = Number((totalAverageStudents / students.length).toFixed(2));

  return averages;
}

@w@
.
.
.
.
.
.
.
.
.
.

export function getStudentAverage(students) {
  const studentsAverage = students.map((student) => {
    return {
      name: student.name,
      average: Number(
        (
          student.grades.reduce((a, b) => a + b) / student.grades.length
        ).toFixed(2)
      ),
    };
  });
  const classAverage =
    studentsAverage
      .map((student) => {
        return student.average;
      })
      .reduce((a, b) => a + b) / studentsAverage.length;

  return {
    classAverage: Number(classAverage.toFixed(2)),
    students: studentsAverage,
  };
}

¡Hola, Platzinauta!
Objetivo
En este desafío, deberás calcular el promedio general de una clase, así como el promedio individual de cada estudiante.
Mi solución,
Se detalla hasta abajo.⬇

export function getStudentAverage(students) {
  //@autor:dmos
  const myClass =
  {
    classAverage: 0,
    students: []
  };
  function myStudent(myName, myAverage) {

    this.name = myName;
    this.average = myAverage;

  };
  function calProm (numbers) {
    const reducedValue = numbers.reduce((suma, number) => suma + number);
    let myCalAverage = reducedValue / numbers.length;

    return (myCalAverage.toFixed(2) * 1);
  }
  students.forEach(element => {

    myClass.students.push(new myStudent(element.name, calProm(element.grades)));

  });

  myClass.classAverage = calProm(myClass.students.map(order => order.average));
  return (myClass);
}

✅ Reto cumplido

🚧
🚧
🚧
🚧
🚧
🚧
🚧
🚧
🚧
🚧
🚧
🚧
🚧
🚧
🚧
🚧

function getStudentsAverage(students){
    // Creo el array de objetos que contiene el nombre y promedio de cada alumno
    const studentsAverage = students.map(student => {
        let sum = 0
        student.grades.forEach(grade => sum += grade)
        return {name: student.name, average: parseFloat((sum / student.grades.length).toFixed(2))}
    })

    // Calculo el promedio del aula 
    let sumAverage = 0
    studentsAverage.forEach(student => {sumAverage += student.average}) 
    const classAverage = parseFloat((sumAverage / studentsAverage.length).toFixed(2))
    
    // Retorno el promedio de la clase y el array de estudiantes y sus promedios respectivos
    return {classAverage, students: studentsAverage}
}

Por aqui mi solucion 🤗
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let averages = {
    classAverage: 0,
    students: []
  };

  students.forEach(student => {
    let calAverage = student.grades.reduce((accumulator, currentValue) => accumulator + currentValue);
    calAverage = calAverage / student.grades.length
    averages.classAverage += calAverage / students.length

    calAverage = Number(calAverage.toFixed(2))

    averages.students.push({
      name: student.name,
      average: calAverage
    })
  });

  averages.classAverage = Number(averages.classAverage.toFixed(2))

  return averages;
}```

Hola! Comparto mi solución:
.








export function getStudentAverage(students) {
  const totalAverage = [];
  const studentsArray = [];

  students.forEach((student) => {
    const average = Number((student.grades.reduce((accum, value) => accum + value, 0) / student.grades.length).toFixed(2));
    totalAverage.push(average);
    studentsArray.push({ name: student.name, average });
  });
  const totalClassAverage = Number((totalAverage.reduce((accum, value) => accum + value, 0) / totalAverage.length).toFixed(2));

  const classAverage = {
    classAverage: totalClassAverage,
    students: studentsArray
  };

  return classAverage;
}

buenas noches a todxs, aqui dejo mi solucion, pero tengo una duda, sucede que no pasa todas las pruebas pero lo probe en mi editor de codigo y obtengo las mismas respuestas que en la solucion, alguien me puede ayudar? gracias

<export function getStudentAverage(students) {
  
    const clase = {
      classAverage: 0,
    estudents: []
  };
let totalAverage =0
let longitud =0
    students.forEach(element => {
        totalAverage += element.grades.reduce((acum,curr)=>acum+curr,0)
        let partAverage = (element.grades.reduce((acum,curr)=>acum+curr,0))/(element.grades.length)
        longitud += element.grades.length
         
        clase.estudents.push({nombre:element.name,average:Number(partAverage.toFixed(2))}) 
    });
    //queda pendiente pulir esta parte!!!!!!!
    
    let promedio = totalAverage/(longitud)
    clase.classAverage = Number(promedio.toFixed(2))
  return clase  
  }
  > 

Aquí envió mi solución:

export function getStudentAverage(students) {
  // Tu código aquí 👈

    let classTotal = 0;
    let studentAverages = students.map(student => {
      let average = student.grades.reduce((sum, grade) => sum + grade, 0) / student.grades.length;
      classTotal += average;
      return {
        name: student.name,
        average: parseFloat(average.toFixed(2))
      };
    });
    let classAverage = parseFloat((classTotal / students.length).toFixed(2));
    return {
      classAverage: classAverage,
      students: studentAverages
    };
  }

Mi solución con la tres formas que se me ocurrieron para obtener los promedios como números con 2 decimales:

export function getStudentAverage(students) {
  // Tu código aquí 👈
  let classAverage = 0;
  let studentsAvg = [];
  students.forEach(student => {
    let average = student.grades.reduce((total, actualValue) => total += actualValue);
    //average = Math.round(average/student.grades.length*100)/100;
    //average = (average/student.grades.length).toFixed(2) - 0;
    average = Number((average/student.grades.length).toFixed(2));

    studentsAvg.push({
      name: student.name,
      average,
    });

    classAverage += average;
  });

  //classAverage = Math.round(classAverage/students.length*100)/100;
  //classAverage = (classAverage/students.length).toFixed(2) - 0;
  classAverage = Number((classAverage/students.length).toFixed(2));

  return {
    classAverage,
    students: studentsAvg,
  };
}
undefined