So i'm trying to see if any of the user is an admin in any event. For some reason, the array will be filled with the index of the last find. Any idea why this is happening?
for(var x = 0;x<=10;x++){
console.log(x);
var current = x;
firebase.database().ref('/Event/' + x + "/admins").once('value').then(function(snapshot) {
console.log(snapshot.val());
if(snapshot.val()==uid){
console.log("Match found at "+(current)+"!");
matchingEvents.push(current);
}
});
}
The array ends up looking like this: [10,10,10,10,10]