Excuse the bad naming of this question, i didnt know what to name it. I am basically doing this math game website. The website asks you a math question and you answer in an input box below. It creates a random number from 1 to 3, decides from multiplication, addition or substraction depending on which number it picked. On another page the user can enable or disable what ecuations they want, for example if they disable multiplication it will update a cookie and it will no longer show the user multiplication questions. But the problem is that i have only come as far as setting the cookie. Ive tried many things but non of them worked. So i dont know what to do know. I would appreciate a little bit of criticism as getting things wrong is the only time you have a chance to get things right.
if (this.value == answer) {
if(answered >= howManyQuestions + 1){
stop();
stopTimer();
}
generate();
document.getElementById('inputAnswer').value = '';
answered++;
}
}
function generate() {
document.getElementById('questionTrack').innerHTML = answered + '/' + howManyQuestions
switch(Math.floor(Math.random() * 3) + 1) {
case 1:
elementOne = Math.floor(Math.random() * 50) + 1;
elementTwo = Math.floor(Math.random() * elementOne) + 1;
document.getElementById('question').innerHTML = elementOne.toString() + ' + ' + elementTwo.toString();
answer = elementOne + elementTwo;
break;
case 2:
elementOne = Math.floor(Math.random() * 50) + 1;
elementTwo = Math.floor(Math.random() * elementOne) + 1;
document.getElementById('question').innerHTML = elementOne.toString() + ' - ' + elementTwo.toString();
answer = elementOne - elementTwo;
break;
case 3:
elementOne = Math.floor(Math.random() * 10) + 1;
elementTwo = Math.floor(Math.random() * 10) + 1;
document.getElementById('question').innerHTML = elementOne.toString() + ' x ' + elementTwo.toString();
answer = elementOne * elementTwo;
break;
}
}```