I want to know how can we get a random math operator to use and process in a math quiz question.
A random question is given to a user to solve, question has only two number to solve for any of the addition, subtraction, multiplication or division.
I have this code to generate two random number.
HTML
<div id="num1"></div><!--end of num1-->
<div id="num2"></div><!--end of num2-->
<div id="operator"></div><!--end of operator-->
<div id="answer"></div><!--end of answer-->
<button onclick="New()">New</button>
Javascript
function New(){
num1=document.getElementById("num1");
num2=document.getElementById("num2");
rnum1 = Math.floor((Math.random()*100)+1);
rnum2 = Math.floor((Math.random()*100)+1);
num1.innerHTML=rnum1
num2.innerHTML=rnum2
}
How can I generate random operator from +-*/ to use and process in code like
operator.innerHTML = '+';
answer.innerHTML = rnum1 + rnum2;