title: Can not access the data in my array using firebase Realtime data
body: <p>So I have 2 playlists created in my database with a playlistName and id. I am trying to display a list of playlists that I have created. I was able Console.log(playlists) to get an array of my 2 objects with the right data in it. but I can't have access to my objects in my array. I tried forEach, map, even just looking at the first index, I always get undefined in my console. Would love some assistance. View Image for console results snipit</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function getPlayLists(b) {
    firebase.auth().onAuthStateChanged(function (user) {
      if (user) {
        var uid = auth.currentUser.uid;
        var playlists = [];
        database.ref(uid).on("value", function (snapshot) {
          snapshot.forEach(function (childSnapshot) {
            playlists.push({
              playlistName: childSnapshot.val().name,
              id: childSnapshot.val().idKey,
            });
          });
        });
        console.log(playlists);
        console.log(playlists[0]);
      } else {
        console.log("No user is signed in.");
      }
    });
  }</code></pre>
  </div>
  </div>
  </p>
  <p><a href="https://i.stack.imgur.com/NAl8i.jpg" rel="nofollow noreferrer">enter image description here</a></p>