How to exit in a loop of object in Firebase after a certain condition. I tried using return false but it doesn't work. Can someone help me. Thanks in advance.
Here is my code:
function checkRoom(room_id,user_id,other_user){
var dbRefObject = firebase.database().ref('chat-list');
//getting all keys
dbRefObject.on('child_added', function (snap) {
if(snap.key == 1){
//if condition succeed the loop will exit
return false; //but return false is not working here.
}
});
}