I'm programming a little quiz that shows you which of the four possible products suits you best.
The different questions are asked with radio inputs and each has the appropriate value
<input class="answer__input" type="radio" id="question1" value="product1" />
<input class="answer__input" type="radio" id="question1" value="product2" />
<input class="answer__input" type="radio" id="question1" value="product3" />
<input class="answer__input" type="radio" id="question1" value="product4" />
In JavaScript i have 4 Variables:
var product1 = 0
var product2 = 0
var product3 = 0
var product4 = 0
Now i want that each time an answer is selected, the respective variable increases by 1
After 10 questions it could look like this:
var product1= 2
var product2 = 4
var product3 = 3
var product4 = 1
At the end of the Quiz i want to output the variable which is the biggest.
How can i do this in JavaScript? I would be very grateful for that help :)