Hey all! I am trying to make a quiz with JS. The idea is that each answer gives certain amount of points to preset variables. In the end, result is the variable with most points. So I was thinking about going in this kind of style:
What would be the best way to set this up on front side? (CSS/HTML)
There are so many options I am not sure what could be the best for this case.
- Code:
var L=0,
K=0,
A=0,
G=0,
B=0,
/* All answers to questions */
a1="Answer1",
a2="Answer2",
a3="Answer3",
b1="Answer1",
b2="Answer2",
b3="Answer3";
var a = document.getElementById("question1answer").innerHTML;
if (a == a1) { L+=4; K+=1; A+=2; G+=5; B+=3; }
else if (a == a2) { L+=4; K+=5; A+=3; G+=1; B+=2; }
else if (a == a3) { L+=4; K+=3; A+=1; G+=2; B+=5; }
var b = document.getElementById("question2answer").innerHTML;
if (b == b1) { L+=1; K+=2; A+=4; G+=5; B+=3; }
else if (b == b2) { L+=1; K+=3; A+=5; G+=4; B+=2; }
else if (b == b3) { L+=3; K+=1; A+=2; G+=4; B+=5; }
What would be the best way to set this up on front side? (CSS/HTML)
There are so many options I am not sure what could be the best for this case.