Simplify Twig/JS loop code
You can select elements by class and give your html elements custom data attributes.

When this is your clickable html element with the corresponding div

&lt;button data-id="dimsTarget4" class="myButton"&gt;
&lt;div class="myContainer" id="dimsTarget4"&gt;&lt;/div&gt;


Your jquery could be

$('.myButton').click(function(){
    var containerId = $(this).data('id');
    $('.myContainer').removeClass( "is-active" );
    $('#'+containerId).addClass( "is-active" );
})


And that's basically it. You'll remove the class from all your divs and add it to the one specified in your data-id attribute.

You won't need any twig elements in your JavaScript (which is much better) and define everything in your twig template. That way your Javascript will behave independently. When you change your html you won't need to change your Javascript that much and you can reuse the code

Note: I just used the button as an example. You can insert whatever class name or html element you like. Since you didn't mention the structure of your html I decided to use a button