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

133
Vistas
JavaScript Filtering

I am trying to build a filter that filters an array based on qualification and years of experience among other criteria after clicking the filtering button, I am new to JavaScript and as such I have encountered many challenges. I've had a challenge incorporating a function for the button that filters the array and returns the desired output. Ideas on how best I can implement this and have fully functioning code will be highly appreciated.

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>APPLICANT FILTERING</title>
</head>

<body>
  <h1>FILTER APPLICANTS</h1>
  <button onclick="newArray()">CLICK TO FILTER</button>
  <p id="demo"></p>

  <script>
    var obj = {
        'applicants': [{
            "name": "Tom",
            "qualification": "degree",
            "experience": 5}, {
              "name": "David",
              "qualification": "certificate",
              "experience": 2},
          ]
        };
        var newArray = obj.applicants.filter(function(el) {
          return el.qualification = 'degree' &&
            el.experience >= 5;
        });
        console.log(newArray);
        document.getElementById("demo").innerHTML = text;
  </script>
</body>

</html>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This should work. In your object, experience is a string (e.g. "5 years"). Instead, you should consider using integer values for this (i.e. 5) because the second expression in your filter (el.experience >= 5) expects a numeric value for experience.

const obj = {
    'applicants': [{
        "name": "Tom",
        "qualification": "degree",
        "experience": 5,
    }, {
        "name": "David",
        "qualification": "certificate",
        "experience": 2
    }, ]
};
const newArray = obj.applicants.filter((el) => (
    el.qualification == 'degree' && el.experience >= 5
));
console.log(newArray);
about 4 years ago · Juan Pablo Isaza Denunciar
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