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

142
Views
how to combine the objective arrays have the save same key in javascript
var saperatedIngredients =  [{
    ingredients: (2) ['Aar maach', 'Fish fillet']
    searchfilter: "marine fish"
    },
    {ingredients: ['Active dry yeast']
    searchfilter: "yeast"
    },
    {ingredients: (5) ['Ajwain', 'Cumin powder', 'Tamarind', 'Tamarind paste', 'Tamarind water']
    searchfilter: "miscellaneous derived edible product of plant origin"
    }
   ]

but i want the output like this

const IngredientsArray = ['Aar maach', 'Fish fillet', 'Active dry yeast','Ajwain', 'Cumin powder', 'Tamarind', 'Tamarind paste', 'Tamarind water']

anyone help me out for this problem

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can simply use flatMap()

var saperatedIngredients =  [{
    ingredients:  ['Aar maach', 'Fish fillet'],
    searchfilter: "marine fish"
    },
    {ingredients: ['Active dry yeast'],
    searchfilter: "yeast"
    },
    {ingredients:  ['Ajwain', 'Cumin powder', 'Tamarind', 'Tamarind paste', 'Tamarind water'],
    searchfilter: "miscellaneous derived edible product of plant origin"
    }
   ]
 
const res = saperatedIngredients.flatMap(x => x.ingredients);

console.log(res)

over 4 years ago · Santiago Trujillo Report

0

You could also use reduce:

const ingredients = saperatedIngredients.reduce( (acc, item) => {
 acc.push(...item.ingredients)
 return acc
}, [])
over 4 years ago · Santiago Trujillo 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!