title: Pure JavaScript JSON compare array
body: <p>I have to compare some JSON data and return index of position. I use pure JavaScript.</p>
  
  <p>I have data below:</p>
  
  <pre><code> NAMES
   [
      {
        "someName" : Name1,
        "secondData" : "aaaa1",
        "thirdData" : bbbb1
      },
      {
        "someName" : Name2,
        "secondData" : "aaaa2",
        "thirdData" : bbbb2
      },
      {
        "someName" : Name3,
        "secondData" : "aaaa3",
        "thirdData" : bbbb3
      },
          {
        "someName" : Name4,
        "secondData" : "aaaa4",
        "thirdData" : bbbb4
      }
  ]
  </code></pre>
  
  <p>and JSON SEATS</p>
  
  <pre><code>[
    {
      "seats" : 0,
      "someName" : "Name4",
      omeData" : null,
      "someData" : null
    },
    {
      "seats" : 1,
      "someName" : "Name3",
      "someData" : null,
      "someData" : null
    },
    {
      "seats" : 2,
      "someName" : "Name1",
      "someData" : null,
      "someData" : null
    },    
    {
      "seats" : 3,
      "someName" : "Name2",
      "someData" : null,
      "someData" : null
    }
  ]
  </code></pre>
  
  <p>All what I want to do is compare this JSON like this:</p>
  
  <pre><code>Take someName from NAMES.someName and search the same name in SEATS.someName if is the same create new array RESULTS. Index in RESULTS array shuldbe SEATS.seats and data from NAMES.
  </code></pre>
  
  <p>Example below</p>
  
  <pre><code>RESULTS[0] = NAMES[{"someName" : Name4,"secondData" : "aaaa4","thirdData" : bbbb4}] 
  RESULTS[1] = NAMES[{"someName" : Name3,"secondData" : "aaaa3","thirdData" : bbbb3}] 
  RESULTS[2] = NAMES[{"someName" : Name1,"secondData" : "aaaa1","thirdData" : bbbb1}] 
  RESULTS[3] = NAMES[{"someName" : Name2,"secondData" : "aaaa2","thirdData" : bbbb2}] 
  </code></pre>
  
  <p>I start do this like this but I stack</p>
  
  <pre><code>for(i=0;i&lt;=459; i++) {
    if(mergeData[i][2] == jsonData[4].rows[i].find(compareElement)) {
    }
  }
  function compareElement(element) {
    return element.someName == i;
  }
  </code></pre>
  
  <p>Problem is if I use find like this I have some error and program stop I can't find way how to solve this.</p>