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

106
Views
Create an object based on a attribute value in an array of object

i have these 3 array

[
  { animals: 'dog', user_id: 12, y: 1 },
  { animals: 'cat', user_id: 1, y: 3 }
]
[
  { Habitation: 'Appartement',  user_id: 1, y: 1 },
  { Habitation: 'Mansion', user_id: 12, y: 1 },
  { xHabitation: 'House', user_id: 1, y: 2 }
]
[
  { device : 'computer', user_id: 1, y: 1 },
  { device : 'laptop', user_id: 1, y: 2 },
  { device : 'tablet', user_id: 12, y: 1 }
]

So these 3 array have something in common : user_id

And i want to create something like this

[
  1 = {
      pets : [{ x: 'cat', y: 3 }],
      house: [{ x: 'Appartement', y: 1 },  { x: 'House', y: 2 }],
      device: [{ x: 'computer', y: 1 },   { x: 'laptop', y: 2 }]
    },
  12 = {
     pets : [{ x: 'dog', y: 1 }],
     house: [{ x: 'Mansion', y: 1 }],
     device: [{ x: 'tablet', y: 1 }]
   }
]

As you can see object are created based on user_id, i dont see/know how to perform a clean code for that in native javascript

Thanks

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!