title: Cannot read property 'then' of undefined with JavaScript promises
body: <p>I understand at first glance this may look like a duplicate but I have seen all the answers for that tell me to put a return in but that is not working.</p>
  
  <p>this is my function:</p>
  
  <pre><code>function removePastUsersFromArray(){
    pullAllUsersFromDB().then(function(users_array){
    var cookie_value = document.cookie.split('=') [1];
    const promises = []
      for (var i = 0; i &lt; _USERS.length; i++) {
        if (_USERS[i].useruid == cookie_value){
        var logged_in_user = _USERS[i].useruid;
          promises.push(
            onChildValue(rootRef, 'users/' + logged_in_user + '/disliked_users/').then(formatUsers)
          )
          promises.push(
            onChildValue(rootRef, 'users/' + logged_in_user + '/liked_users/').then(formatUsers)
          )
        }
      }
      return Promise.all(promises);
    })
  };
  </code></pre>
  
  <p>and I get the error at this function:</p>
  
  <pre><code>function displayRemovedPastUsersFromArray(){
    removePastUsersFromArray().then(function(promises){
  </code></pre>
  
  <p>basically saying that my <code>removePastUsersFromArray</code> is undefined. but it isn't as it clearly exists above and returns promises??</p>