So I have a very simple math tutoring page I'm working on for a final project in college. The project is done concerning the problem statement, but there is one part that I'd like to "take the extra mile".
Here is what the page looks like:
Basically, there is a button that generates a new number in two text boxes. The user is asked to find the difference between those two random numbers, put his answer in the answer box. When ready, the user clicks the "check answer" button.
That is all done. The only thing I would like to further add to this tool is that when the user clicks the "New Problem" button, I want to be sure that the first number is always larger than the second number ( so that the user never has to give a negative answer).
So basically, I just need to know how to program the "New Problem" button for the subtraction page. Here is what I have now:
Its not working... Here is a link to the page itself: http://bennyboy.us/cs/math/sub.html I just need to make sure that each time the user clicks "New Problem", that random number "a" is always larger than random number "b". Does someone have advice on how to accomplish my task? Thank youCode:function newProbSub() { var a, b; a = document.getElementById('randNum1').value = Math.floor(Math.random()*25); b = document.getElementById('randNum2').value = Math.floor(Math.random()*25); document.getElementById('answer').value = 0; if (a<b) { document.getElementById('randNum1').value = Math.floor(Math.random()*25); } else { } }![]()
Bookmarks