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

192
Vistas
filter an array of objects which contains key value pairs where value is an integer

My Array looks like this

filtervalue = xy

arr = [{id:123, name:'xyz'}, {id:122, name:'xyy'}, {id:134, name:'zzz'}]

arr.filter((i) =>
          name.includes(filtervalue)
        );

above gives me the expected output as below

[{id:123, name:'xyz'}, {id:122, name:'xyy'}]

I'm trying to do the same thing with the id. it gives me an error

.includes is not a function.

like, when my filterval = 12

expected output should be as below

[{id:123, name:'xyz'}, {id:122, name:'xyy'}]

how do i achieve this ?

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

0

Please use filter function like this.

const filtervalue = 12

const arr = [{id:123, name:'xyz'}, {id:122, name:'xyy'}, {id:134, name:'zzz'}]

const result = arr.filter((val) => val.id.toString().includes(filtervalue.toString()))

console.log(result)

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