I am new in firebase and I'm trying to pass a $variable in a function to check if the $variable is exists.
function ifExistWaybillNo(waybill_no)
{
  var databaseRef = firebase.database().ref('masterlist');
  databaseRef.orderByChild("waybill_no").equalTo(waybill_no).on('value', function(snapshot){
    alert(snapshot.exists()); //Alert true or false
  });
}
The above function work's fine but when I changed alert(snapshot.exists()); to return snapshot.exists(); it doesn't working. It just return undefined, which should return true or false.
How can I do this? thanks in advance
 
     
    