Search code examples
typescriptif-statementconditional-operator

How to simplify statement


How to simplify statement? Admin can have unlimited count users

public get isUsersLimitReached(): boolean {
  return this.isAdmin ? false : usersCount >= this.max_users;
}

Solution

  • If by "simplify", you mean "shorten", then this is as good as it gets:

    public get isUsersLimitReached(): boolean {
      return !this.isAdmin && usersCount >= this.max_users;
    }
    

    Other than that, there's really not much to work with here.