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

211
Views
Can you merge an array of object into just one "big" array?

I need to filter based on a search of words, When I look up one word it pulls up what I need, but I've been having some trouble when it comes to seaching for multiple words that meet the requirements. So the thing is, I need to keep the previous search and add into this array the next results from the second word.

/* ===== Search images by keyword =====*/
searchByKeyword() {
  if (this.searchText != "" && this.searchText != null) {
    if (this?.plansBeforeSearch?.length == 0) {
      this.plansBeforeSearch = this.selectedPlans;
    }
    this.searchTextDivision();
    for (let i = 0; i < this.searchTextArray.length; i++) {
      /* this.filteredImages = */
      this.test[i] = this.planCollection
        .filter(
          (pl) =>
            this.plansBeforeSearch.find((p) => p.name == pl.name) != null
        )
        .filter((plan: Plan) => {
          return [
            plan.id,
            plan.code,
            plan.name,
            plan.gallery,
            plan.tags,
            plan.brand,
            plan.description,
            plan.width,
            plan.depth,
            plan.sqf,
            plan.bedrooms,
          ].some((field) =>
            field
              ?.toString()
              ?.toLowerCase()
              ?.includes(
                this.searchTextArray[i].toString().toLowerCase().trim()
              )
          );
        });
    }
    
    this.filteredImages = this.test[0];
    console.log(this.test);
    console.log(this.filteredImages);
  } 
}

I created an array of the words I want to use and for each loop I kept them on this test array. It keeps all images that meet the requirement enter image description here But when I pass it to the filteredImages array that is the one that displays the images, I can only pass ONE position. So in the code I shared I set up the first position to show, but I need all three of them!

I thought maybe if I merge all the arrays that the test array has into one array with one position only I can pass that to the filteredImages

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try with flat array:

this.filteredImages = this.test.flat()
about 4 years ago · Juan Pablo Isaza Report
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!