title: Accessing a value in an object of unknown name that is stored in an array (JavaScript)
body: <p>Its hard to give this question a good name. I'll jump right into the example:</p>
  
  <pre><code>var people = [
          {
              john: {
                  score: 1
              }
          },
              {
              adam: {
                  score: 2
              }
          }
      ];
  </code></pre>
  
  <p>I need to loop through this array of objects and get the <code>score</code> values, the trick is I don't know the names (<code>john</code>, <code>adam</code>, ...) but I know each contains a <code>score</code> value.</p>
  
  <p>How do I get them? My current code looks like this:</p>
  
  <pre><code>var pplArr = [];
  
  for (i=0; i&lt;people.length; i++) {
      for (var key in people[i]) {
          pplArr.push(key);
      }
  }
  
  for (j=0; j&lt;pplArr.length; j++) {
      console.log(pplArr[j]);
      //var nameVar = eval(pplArr[j]);
      //console.log(people.[j].nameVar.score)
  }
  </code></pre>
  
  <p>The commented section doesn't work since <code>eval()</code> returns undefined otherwise I think it would work. I also tried <code>for (var key in people)</code> and its variations with limited success. Also my two loops look like they are over-complicated, is there no simpler way?</p>
  
  <p>I'm using AngularJS (ionic) thus I would prefer not to use jQuery.</p>