I have a form that asks the user for maximum result in math drills, in order to build some drills:
<input type="text" id="maxR" placeholder="type maximum result" />
<button id="activate" onclick="makeDrills()">MAKE</button>
<p id="drill"></p>
And I want to translate all the drills options with their answers as arrays.
I need help with translating this sentence into java-script:
"While c > level add new array of theQ with the both the drill and it's result".
This is my attempts:
<script>
function theQ(quest, ans) { // drills constructor
this.question = quest;
this.answer = ans;
}
var a, b, c ; // arguments
var quests = [new theQ()]; // arrays holder
var level = document.getElementById("maxR").value; // user input
function makeDrills() { // button pushed
var c = a+b; // pattern of each drill
while (c > level) { // as long result smaller then user input
var a = Math.floor(Math.random() * 10); // choose random number
var b = Math.floor(Math.random() * 10); // choose another random number
quests.push("a+b", "c"); // add the drill to the arrays holder
}
document.getElementById("drill").innerHTML += quests; // print drills
}
</script>
I read similar questions and try to use their techniques but didn't succeed.
edited: This code is for educational purpose:
a,b,c are arguments on a+b=c equation. I try to make math drills generator that the kid enter maximum result and push the button and then all possible drills options will appear. I need to put all the options as arrays because I want to use the options as sort of a test.
So for now I just want to understand how to create those arrays.
cwhen you generate randomaandb? Also please consider showing "what's wrong" with your current code, is there any errors? What is the unexpected behavior now?