I understand how callbacks work and have successfully created a callback, however I can not get my code to return within the function:
var verifypassword = function(username, password, callback){
      var connection = mysql.createConnection({
           host     : 'hostexample',
           user     : 'jenn',
           password : 'secret',
           database : 'dbexample'
      });
      connection.connect();
      var query = "SELECT _password " +  "from User_Info WHERE username =?";
      connection.query(query, [username], function(err, rows, fields) {
      if (err) return callback(0);
      var string = JSON.stringify(rows);
      var json = JSON.parse(string);
      var correctpassword = json[0]._password;
      return callback(correctpassword);
      });
 }
Then when I call an instance of the verifypassword function:
var verified = verifypassword(username, password, function(correctpassword){
         //console.log(correctpassword);
         return correctpassword;
     });
console.log(correct);
//prints undefined     
If I try to print console.log(correct) in the callback function it will, but it does not return correctpassword.
Any help is appreciated
