Im trying to validate radio input to check if its correct answer.
But it skips the line if (answer == allQuestions[q].correctAnswer)
here is whole code https://jsfiddle.net/alcatel/sopfmevh/1/
for (let k = 0; k < answers.length; k++) {
if (answers[k].checked) {
answer = answers[k].value;
}
}
// IT SKIPS THIS LINE !!
if (answer == allQuestions[q].correctAnswer) { // IT SKIPS THIS LINE!!
alert("correct");
}
q++;
populate();
Aucun commentaire:
Enregistrer un commentaire