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

162
Vistas
Sorting an array / table in JavaScript with keywords

I have a simple list and I am trying to create a search filter for this, you enter a keyword and it goes through the function and re-sorts this data list to show only ones that apply to the keyword

list: [
  {name: "Apple"},
  {name: "Grape"}
]
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try Array.prototype.filter()

var list = [
  {name: "Apple"},
  {name: "Grape"}
];
var filtered = list.filter(function(o){
  return o.name == "Apple";
});
about 4 years ago · Juan Pablo Isaza Denunciar

0

ili is right, Array.prototype.filter() is the good way but it would be much better with a String.prototype.includes() too, because the current answer can only works if the person type exactly the good word. Here is an implementation more user-friendly :

list = [
  {name: "Apple"},
  {name: "Grape"}
]

input = "app"

filtered = list.filter(element => {
    if(element.name.toLowerCase().includes(input.toLowerCase())) {
        return element
    }
})

console.log(filtered)

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