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

100
Views
Cree un objeto basado en un valor de atributo en una matriz de objetos

tengo estas 3 matrices

 [ { 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 } ]

Entonces, estas 3 matrices tienen algo en común: user_id

Y quiero crear algo como esto.

 [ 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 }] } ]

Como puede ver, los objetos se crean en función de user_id, no veo/sé cómo realizar un código limpio para eso en javascript nativo

Gracias

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!