combine

Structure merge

Swiftlikeninja's picture

I have a structure like the one in the attached picture, Im struggling with a means of combining all the indexes together. so for example the output structure would be ['61405075','6140232'], basically merging the structure together by index.

can anyone assist me with some javascript snippets to point me in the right direction?

Combine Like Keys into String

Swiftlikeninja's picture

I have been messing around with a javascript patch that will loop through a structure (about 1000 entries) and parse out the similar keys into single strings. the Code im using is as follows:

function (__structure structureOut) main ( __structure structureIn)
{
   if (!_testMode) {
 
        var Rebuild = new Object();
 
        for(i = 0; i <structureIn.length; i++) {
           Rebuild[structureIn[i][0]] +=structureIn[i][1];
          }
 
           var result = new Object();
           result.structureOut=Rebuild;
          return result;
   }
}

but the end results have an extra 'undefined' entry at the beginning of each new string. Can anyone explain why this is occurring? I've attached a sample compostion to better show.