dimanche 27 septembre 2015

How can I create a random math statement and have the computer solve it?

a = Math.random();
b= Math.random();

az = Math.round(a);
bz = Math.round(b);

var chooseoperator = ['+','-','*','/'];


var operator = chooseoperator[Math.floor(Math.random() *chooseoperator.length)];

var final=az+operator+bz;

alert(final);

So the computer alerts,"1-0" or something similar. How can I make the computer solve it?




Aucun commentaire:

Enregistrer un commentaire