title: How to return variable, that's not in scope?
body: <p>I try to access the <code>results[0].guess</code>, to return them to the caller. The <code>console.log(getGuess(12,4)</code>(the parameters are not important) just returns undefined. How do I have to access the result?</p>
  
  <p>Note: I am using Node.js with mysql.</p>
  
  <pre><code>var getGuess = function(userId, gameId) {
  var query = 'SELECT * FROM guesses WHERE user_id = ' + connection.escape(userId) + ' AND game_id = ' + connection.escape(gameId);
  connection.query(query, function(err, results) {
  if (err) {
    console.log(err);
    return;
  }
  var guess = results[0].guess;
  return;
  });
  return guess;
  };
  </code></pre>