title: How do you return inside a promise?
body: <p>I'm beginning to teach myself javascript and am having trouble returning from a function inside a promise. My code, essentially, looks like this:</p>
  
  <pre><code>foobar = function(x,y){
      //code that doesn't matter
      return promiseFunction(
          function(results){
             console.log("promise completed")
             console.log(output)
             return output;}
          function(err){throw error;});
  
  console.log(foobar('1','2'));
  </code></pre>
  
  <p>This prints </p>
  
  <pre><code>undefined
  promise completed
  what I want the result to be
  </code></pre>
  
  <p>I'm new to asynchronous programming and am not certain what I am doing wrong.</p>