How can I loop my quiz answers to get a final score
So far I have declared the canidates name, canidates response, correct response, and created an input.question for questions 1-5. Now i am wanting to loop the answerKey to give a percentage result, but I am not sure how to make the system read the correct answers as numbers instead of strings. I want my final output to be let score='';
and have it read a percentage for the overall grade of the quiz. Can someone help me out with this?
Voters
You can add a score variable at the top. Every time the candidate answers a question, you can use an if statement to check if the answer given is the same as the actual answer, if it is you can add 1 to score. Then at the end you can do
score/<number of questions>
to get the percentage.Thank you!
@ash15khng