Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

260
Views
How do I filter values in an object to display an array of values

How do I fix my honorRoll function at the bottom so that it displays the names of all the students with GPA higher than the benchmark of 3.5?

Right now all I get back is an empty array, I would like to see [Bianca Pargas, Sameer Fares].

const GPA_BENCHMARK = 3.5;

let students = {
  1: {
    name: 'Egill Vignission',
    gpa: 3.4
  },
  2: {
    name: 'Bianca Pargas',
    gpa: 3.8
  },
  3: {
    name: 'Aisling O\'Sullivan',
    gpa: 3.4
  },
  4: {
    name: 'Sameer Fares',
    gpa: 3.9
  }
}

let honorRoll = Object.values(students).filter(student => {
  return students.gpa >= GPA_BENCHMARK;
});

console.log(honorRoll);

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

in a very simple way you can do like that

const GPA_BENCHMARK = 3.5;

let students = {
  1: {
    name: 'Egill Vignission',
    gpa: 3.4,
  },
  2: {
    name: 'Bianca Pargas',
    gpa: 3.8,
  },
  3: {
    name: "Aisling O'Sullivan",
    gpa: 3.4,
  },
  4: {
    name: 'Sameer Fares',
    gpa: 3.9,
  },
};

let honorRoll = [];
for (let key in students) { 
  if (students[key].gpa >= GPA_BENCHMARK) {
    honorRoll.push(students[key]);
  }
}

console.log(honorRoll);
 
about 4 years ago · Juan Pablo Isaza Report

0

You used students instead of student in your filter fn

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!