Menu
why does the explanation “That is correct” precede the score when i press the submit button? I don’t want it to do this, I just want it to give the score upon submit. the onclick=checkans() is at the end of the html.
function CheckAns(question, answer) {
yourAns[question]=answer;
if(answer == ans[question]) {
alert(“That is Correct!”);
}
else {
alert(“Incorrect!:”+ explainAnswer[question]);
}
CorrectNum=0
for(i=1; i<=10; i++) {
if(ans[i]==yourAns[i]) {CorrectNum++;}
}
alert(“Your total score is “+CorrectNum+” out of
10.”);
}