I am pulling an object from firebase converting it to an array then doing remove element operation on it but there is some strange behaviour:
this.players = this.db.object('arena/players').valueChanges();
this.players.subscribe(players =>{
console.log(players);
this.playersarray= Object.keys(players).map(key => ({ key, value: players[key] }));
console.log(this.playersarray);
console.log(this.playersarray.length);
for(var i =0;i<this.playersarray.length;i++){
if(this.playersarray[i].value != "waiting"){
console.log(this.playersarray[i].value+"deleting");
this.playersarray.splice(i,1);
}
}
console.log(this.playersarray);
});
I am trying to remove elements which value are not equal to waiting.So in this case im expecting to remove engincan,lifesuxtr and get last console.log as only someotheruser,someuser but lifesuxtr is not removed ??? only engincan removed ?
