Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

116
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda