JSFiddle - React, Tailwind, and code Playground

HTML

<input type="radio" name="r1"><br>
<input type="radio" name="r1"><br>
<hr>
<input type="radio" name="r2"><br>
<input type="radio" name="r2"><br>
<input type="radio" name="r2"><br>

JavaScript

$(function(){
    $(jQuery.unique(
        $('INPUT:radio')
            .map(function(i,e){ 
                return $(e).attr('name') }
            ).get()
    )).each(function(i,e){
        $('INPUT:radio[name="'+e+'"]:visible:first')
            .attr('checked','checked');
    });
});