title: Javascript - Help retrieving data from Firebase
body: <p>I have this code below to retrive data from firebase and turn into an array but whenever i call it it stops other functions from being called inside the code even tho I can perfectly call them in the console.</p>
  <p>I've worked around this by using callback functions but I am at a point it just doesn't do anymore. How can make this part act like a normal function where I can call anytime without stopping the code.</p>
  <pre><code>function genList(){
      dataRef.on('value', data =&gt; {
      let arr = (data.val());
      let keys = Object.keys(arr);
      for (let i = 0; i &lt; keys.length; i++) {
          let k = keys[i];
          let title = arr[k].title;
          let author = arr[k].author;
          let pages = arr[k].pages;
          let date = arr[k].date;
          let bookmark = arr[k].bookmark;
          let newList = new Object();
          newList.title = title;
          newList.author = author;
          newList.pages = pages;
          newList.date = date;
          newList.bookmark = bookmark;
          bookList.push(newList);
      }
  })}
  
  </code></pre>