Showing Buttons based on Member Roles

If you’re looking for a specific role, you can do it with shorter code.
Instead of this for loop, you can do:

isVolunteer  = !!roles.filter(e => e._id === 'xxxx').length;

It filters the roles and only leaves the matching value, then it checks if the filtered array has length or doesn’t have length.

1 Like