I have an array of objects which is called users and it's defined in my component as `users: Array<GroupUser> = [];`, my goal is to check if new applicant doesn't have the same id as any of users that are already present in array.

Here is my model for GroupUser:

```
export class GroupUser {
  id?: number;
  user: number;
  permissions: string;
  confirmed?: boolean;
}

```

I receive applicant's data with id that you manually type in input from backend in this function:

```
onKey(event: any) {
  this.adminId = event.target.value;
  this.authService.getSpecUser(this.adminId).subscribe(
    (data => {
      this.admin = data;
    })
  );
}

```

So basically I want to check if adminId (`adminId: number;` in my component) equals to any users.user value that are already present in my array.

I've tried to use different functions to achieve the result:

```
for (let i = 0; i < this.users.length; i++) {
    if (this.admins.indexOf(this.users[i]) !== -1) {
      this.users.push({user: this.adminId, permissions: this.g.admin_rights.value});
    }
  }

for (let i = 0; i < this.users.length; i++) {
       console.log(this.users[i].user, this.adminId)
       if (this.users[i].user != this.adminId) {
         this.users.push({user: this.adminId, permissions: this.g.admin_rights.value});
      }
     }

```

But new users are being added to array even if they have the same id. I think some() method can help but I'm not sure how to use it correct here.

So basically I'm trying to check if user is already in group before adding him there. There are a lot of users on platform and many groups for these users and before I'm adding new user to group and I must check if he is already there.

Any help would be appreciated.