title: Get array of items from Firebase snapshot
body: <p>I'm trying to get an array of items from my Firebase database, using a snapshot generated on page load. I've added the value of each object to an array, and now I'm trying to push an item from each object into another array with a for loop. </p>
  
  <p>But when I create the second array, there are more items in it than there are objects in the snapshot. </p>
  
  <p>I'm wondering how I can get around this. Any help would be awesome. Thanks.</p>
  
  <p>Code: </p>
  
  <pre><code>var ref = firebase.database().ref().child('/scenes/' + projId).orderByChild('wordcount');
  ref.once('value',function(snap) {
      snap.forEach(function(item) {
          var itemVal = item.val();
          keys.push(itemVal);
          for (i=0; i &lt; keys.length; i++) {
              counts.push(keys[i].wordcount);
          }
      });
  });
  </code></pre>