In my Class I declared an Array
myUsers = new Array();
Where I want to Add Usernames, unique. So i thought I would check if the ArrayLenght is 0, if yes, add a User. Which works fine. I if a Username wants to be added, which exists in the Array, it should be deleted. But this way, If I add one User the console says ["User1"] If I try to add another one (another one User2) the console says ["User1", empty] Can't get behind that...
isChecked(e) {
var usersArray = this.myUsers;
console.log(usersArray.length);
if(this.myUsers.length == 0) {
console.log("is 0");
this.myUsers.push(e);
} else {
console.log("is not 0");
for (var i= 0; i < this.myUsers.length; i++) {
if (this.myUsers[i] == e) {
console.log("is in array");
delete this.myUsers[i];
} else {
this.myUsers.push(e);
}
}
}
}