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

109
Views
how to merge data from different array to a combined array in json form

how to merge data from different array to a combined array in json form.

 let NAME: any[] =[]
  let TYPE: any[] = []
  let OBJ: any[] =[]


  for (var i=0;i<getdata.length;i++)
  {
    var p =getdata[i].name;    
    **var a =NAME.push(p);**     // pushing data to Name

    for (var j in getTypes[i])
    {
    if (getdata[i].name ==getTypes[i][j].data.name) // get type is having req. data here
      {

        var k = getTypes[i][j].name ;
        **var s =TYPE.push(k);** //pushing data to type

      }
    }
      for (var j in getobj[i])
    {
      if (getdata[i].name ==getobj[i][j].library.name)         
      {
        var o = getobj[i][j].name ;
        **var g = OBJ.push(o);** // pushing data to OBJ
      }
    }
  }     
 
  console.log(NAME);   // result getting :- ['A','B','C']
  console.log(TYPE);    // result getting :- ['A1','A2','B1','B2','C1','C2']
  console.log(OBJ);   // result getting :- ['AA1','AA2','BB1','BB2','CC1','CC2']
});

Data required like this :

{ id=1; NAME: A OBJ:'A1','A2' TYPE:'AA1','AA2' }

{ id=2; NAME: B OBJ:'B1','B2' TYPE:'BB1','BB2' }

{ id=C; NAME: C OBJ:'C1','C2' TYPE:'CC1','CC2' }

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

0

const NAME = ['A','B','C']
const OBJ = ['A1','A2','B1','B2','C1','C2']
const TYPE = ['AA1','AA2','BB1','BB2','CC1','CC2']

const result = []
NAME.forEach((item, index) => {
  const obj = []
  const type = []
  obj.push(obj[index], obj[index + 1])
  type.push(type[index], type[index+1])
  result.push({
    id: index + 1,
    NAME: item,
    OBJ: obj,
    TYPE: type
  })
})

return result
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!