I have the following function:
var checkExist = function(_id) {
  var t;
  car.count({
    id: _id
  }, function(err, c) {
    if (c != 0) {
        t = 0;
        console.log(t);
    } else {
        t = 1;
        console.log(t);
    }
  });
  console.log(t);
  return t;
}
The problem: 't' is undefined at the end of the function, but it changes values inside of the if/else block. Any suggestions how to solve this?
merci
 
     
    