When I console.log result it gives me the result, but then when I console.log outside the function, its undefined. Both Console.log return undefined. Using Javascript and Node.js (mongoDB database).
function getAllScores() {
  var scoresFromDb = db.account.find({}, { username: 1, score: 1 }).toArray(function(err, result) {
    if (err) throw err;
    return result;
  })
  return scoresFromDb;
}
var allScores = getAllScores();
console.log(allScores + ' all'); 
console.log(getAllScores());
