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