I have quite a simple problem, but since I'm new to programming I really would like your help.
So basically I have a small HTML/php textboxes on my site where student can fill in answers. I want a for loop to compare these answers to a correct answers and see it there is a match.
What I'm trying to do:
- Make a list of all the student answers
- Make a list of all the Correct answers
- Make a for loop
- In that forloop make an if statement that compares the 2 (text)answers
- Have a variable names SCORE += 1.
so here is what I have so far:
const Student_Answers_1a = document.getElementsById("Antwoord1a");
const Student_Answers_1b = document.getElementsById("Antwoord1b");
let Answers_Students = [Antwoord1a, Antwoord1b]
let Correct_Answers = ["SELECT title FROM movies;", "SELECT director FROM movies;"]
var Score_Student = 0
for (var i = 0; i < Answers_Students.length; i++) {
if (Answers_Students[i] === Correct_Answers[i]) {
Score_Student += 1;
} else {
}
}
Aucun commentaire:
Enregistrer un commentaire