0

What I have is an object with three members. Each of these members has an array of objects each with new members. So accessing an "inner" member would be done like this.

outerObject.outerObjectMember[innerObjectPlacementInArray].innerObjectMember;

In each of the three outer members there's an inner object in the array with a value (id) that is equal to a value in both of the other outer members inner objects members. There are no duplicate ids in either outer member. What I want to do is create objects that are made by joining all the inner objects on the (id) value resulting in objects that have the properties of each inner member with the same id.

Finally these objects should be in an array.

I know it can probably be done using a lot of loops and ifs but I was wondering if any method existed or if someone had a nice and quick(perfomance-wise) solution

Does this make sense or does it need further clarification ?

PNS
  • 750
  • 1
  • 5
  • 19

1 Answers1

0

So you want to change this:

var outer = {
    om1 = [
        im1_1, common_id, im1_3...
    ],
    om2 = [
        im2_1, im2_2, common_id...
    ],
    om3 = [
        common_id, im3_2, im3_3...
    ]
}

into... what exactly?

I know this isn't quite right, but I'm watching the Olympics & I need to go to bed. Maybe this can help you clarify for others.

Anyway, you need to use a loop or two :)

Nick
  • 5,995
  • 12
  • 54
  • 78