title: issue with Mongoose assigning JSON to variable
body: <p>Thank you in advance for anyone that reads this. I really appreciate any and all help.</p>
  <p>so this is my first app personal app. I have setup a DB in Atlas on mongodb.com and I can write to it with out an issue. But when my app tries and pull from my db I can get it to print to console. But I am able to assign the data to any variable to use anywhere else in my my app.</p>
  <p>here is my code that works to print to the console. But not sure what setup or package I am missing so i can store it as a local variable. I am using a callback function to return the api call and the console print out works. just dont know what to do next</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 getTerms() {
      
      let allTerms = []
      termAdd.find({}, '_id', (err, term) =&gt; {
              
              term.map((term) =&gt; {
                  allTerms.push(term)
                  // if I understand Push() correctly this should store my output to allTerms.
              });
  
              //this works to print out to console in JSON.
              console.log(allTerms, 'getTerms')
              return allTerms;
              
          });
      };
      
      
      if (res.statusCode === 200) {
          //callback function to return the console from the function
          getTerms()
  
         // when i do a let foo = getTerms() it will return undefined
         //so I am really dont understand how to assign the return from 
        //the function to a variable. 
  
  
          //How do I assign this console output to variable to use for output
  
          console.log('200 statusCode')
      };
  
          //Random Number Generator
          let ranNum = Math.floor((Math.random() * 10) + 1);
          console.log('random number = ',ranNum);
  
          res.render('fs', {
              flashCard : 'Test Card',
              items: ranNum
          });
      
  });</code></pre>
  </div>
  </div>
  </p>
  <p>I have the full code on GitHub if that would help I can link to this project.</p>
  <p>Should I be using a delay in anyway. I was given a suggestion. But I did not understand what I was reading.</p>