Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!