function returns undefined when I want to find documents from dababase in mongoose : <p>As I said, I want to create a function that have to arguments, username and email. If one of them is in the database, then user can't register.</p>

<pre><code>function checkAll(username, email) {
  let num = 0;
  User.find({}, (err, result) =&gt; {
    if (err) throw err;
    for (let i = 0; i &lt; result.length; i++) {
     if (username === result[i].username || email === result[i].email) {
        num++;
      }
    }
    db.close();
    if (num == 0) {
      return true;
    }
    return false;
  });
}

console.log(checkAll("test", "test@test.com"));
</code></pre>

<p>I know that <code>User.find()</code> is an asynchronous function that have a second arguments that it is a callback, but my question is: <strong>Why does it return undefined??</strong></p>
