Is there any method specifically designed for this, or do I have to iterate over the group array in api.getCurrentUser()?

There isn’t a method specifically for it. But you can check membership of a group using something like
api.getCurrentUser().groups.any(g => g.name === "team")