JSFiddle - React, Tailwind, and code Playground

HTML

Question : did you like the training?

<input type="radio" name="q4" value="Yes"> Yes
<input type="radio" name="q4" value="No"> No
    
<button id="getval">Get value</button>

JavaScript

var ch = document.getElementsByName('q4');

for (var i = ch.length; i--;) {
    ch[i].onchange = function() {
        alert(this.value);
    }
}

document.getElementById('getval').onclick = function() {
    var checked = document.querySelector('[name="q4"]:checked');
    alert(checked ? checked.value : 'Not selected');
}