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.
function checkAll(username, email) {
  let num = 0;
  User.find({}, (err, result) => {
    if (err) throw err;
    for (let i = 0; i < 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"));
I know that User.find() is an asynchronous function that have a second arguments that it is a callback, but my question is: Why does it return undefined??
 
     
    