I havn’t ever used a forEach loop you would be correct… so I’ve replaced with the for loop and tweaked the else statement at the bottom. Why do I still feel like its not targeting the <p> element or is it?
function checks() {
var radioSets = document.querySelectorAll(".answers-div");
for (var i = 0; i < radioSets.length; i++) {
var radioButtons = [ ...radioSets.querySelectorAll('input[type=radio]') ];
var newVar = false;
for (var i = 0; i < radioButtons.length; i++) {
if (radioButtons[i].checked) {
newVar = true;
break;
}
}
if (newVar == true) {
radioButtons.class.remove(".message_visible");
}
else {
radioButtons.class.add(".message_visible");
}
}
radioButtons is an array and not the applicable p element. You should target the radio button set and add/remove the class from the class list (research this part).