Coding Challenge: Students Results

Let's practice how to return the names and average marks of only the female students from a list of students.

Problem statement

Complete the following program to compute and return the female student’s results (name and average grade). Refactor it using functional programming. Execution results must stay the same.

Input

const students = [
  {
    name: "Anna",
    sex: "f",
    grades: [4.5, 3.5, 4]
  },
  {
    name: "Dennis",
    sex: "m",
    country: "Germany",
    grades: [5, 1.5, 4]
  },
  {
    name: "Martha",
    sex: "f",
    grades: [5, 4, 2.5, 3]
  },
  {
    name: "Brock",
    sex: "m",
    grades: [4, 3, 2]
  }
];

Expected output

[ { name: 'Anna', sex: 'f', grades: 4 },
  { name: 'Martha', sex: 'f', grades: 3.625 } ]

Coding exercise

Get hands-on with 1400+ tech skills courses.