xxxxxxxxxx
29
var num1;
var num2;
var ans;
var Qans;
function setup() {
createCanvas(400, 400);
ans = createInput();
ans.position(20, 65);
num1 = Math.round(random(1,10));
num2 = Math.round(random(1,10));
}
function draw() {
background(220);
if(keyDown("space")){
num1 = Math.round(random(1,10));
num2 = Math.round(random(1,10));
}
textSize(32);
text(num1+" + "+num2, 20, 50)
Qans = num1 + num2;
if(keyDown("space")&&(ans == Qans)){
console.log("Correct");
}
}