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

115
Vistas
Test if array has value

I have a array that I fetched from git HUB api,

[{
 id: 362784382,
 imageURL: "https://raw.githubusercontent.com/CRISTIAN-MULLER/BookShelf-Backend/main/Tela.png",
 name: "BookShelf Backend" ,
 ownerName: "CRISTIAN-MULLER",
 topics: ["javascript","reactjs"]
},
{
  id: 362784383,
  imageURL: "https://raw.githubusercontent.com/CRISTIAN-MULLER/BookShelf- 
  Backend/main/Tela.png",
  name: "BookShelf" ,
  ownerName: "CRISTIAN-MULLER",
  topics: ["other tag","react"]

}

]

This data has tags with languages that I used in My projects,

In another part of my code i have a function that iterates trough this array and returns a array of tags with unique names.

const topicsWithoutDuplicates = [...new Set(topics.flat())].map((elem) => ({
    id: elem,
    title: elem,
  })); 

I render for each element a button im My portfolio page, and I need to when i click a button , iterate all data and return only the projects that has the topic matching the button ID,

I'm trying to construct a function that do this, but I'm stuck, "selected" has an array of strings with the buttons pressed ["javascript", "react", ....],

I know that includes Method receives only strings as arguments and thats way this is not working, so I need to get the "selected" array and for each, item iterate over the received data from github and return only the elements that has in topics the same name that I have in selected array.

so basicaly i need to iterate an array over another array comparing each element.

  const filteredData = userData.filter((item) =>
      item.topics.map((topic) =>
        topic.includes(selected)
      )
    );

How can I do that?, I'm not thinking anymore.

about 4 years ago · Juan Pablo Isaza
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