Tabbed interface with Stimulus

Hi there,

I made a small stimulus controller to show and hide tabs based on which tab the user clicks. It’s similar to the slideshow example on the Managing State page.

Here’s a link to the fiddle:
…and the gist:

It works well, but I’m not super-happy with the dual loops for activating the tab and the pane. Does anyone have any ideas for improving it?

Also, you’re welcome to use it for inspiration or copy it in your project!

Here’s my attempt: