title: Creating an array of objects using an array of each object's name
body: <p>I feel tantalizingly close here. Scenario: I have a JSON sent in a message that looks something like this:</p>
  
  <pre><code>{"objects": {
      "object_name1":{ 
          "name":"object_name1",
          "otherData":"some other data"
      },
      {"object_name2":{ 
          "name":"object_name2",
          "otherData":"some more data"
      }
  }}
  </code></pre>
  
  <p>As you can see, the objects are not in an array. I created an array containing each Object's string name using the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys" rel="nofollow noreferrer">Object.keys</a> function and then created <em>another</em> array which contains the objects that I want using an if statement, which leads to my current question:</p>
  
  <p>How can I create an array of objects using the string values (the object keys) contained in the array I have created?</p>
  
  <p>I've tried something like this:</p>
  
  <pre><code>filteredKeyArray = ['object_name1','object_name2'];
  newObjArray = [];
  for(i in filteredKeyArray){
      for(key in objects){
      newObjArray.push(objects[i[key]]);
      }
  }
  </code></pre>
  
  <p>But the <code>newObjArray</code> is just displaying all undefined. Ideally the <code>newObjArray</code> displays something like this:</p>
  
  <p><code>[{"object_name1":{...}},{"object_name2":{...}}]</code></p>
  
  <p>Thoughts?</p>