Each time the arithmetic question is generated and whenever i pick the right or wrong answer the statement of function checkanswer() always goes on if-statement “Correct”. How am i able to create if/else statement correctly base on an arithmetic question varanswer = var1 + var2
function checkAnswer(event) if(questionGen(varAnswer) \> 1 ) then instructionsText.text = "Correct!"; instructionsText:toFront() generateBalls() for i=1, allBallsGroup.numChildren do display.remove(allBallsGroup[1]) end else instructionsText.text = "Incorrect!"; instructionsText:toFront() generateBalls() for i=1, allBallsGroup.numChildren do display.remove(allBallsGroup[1]) end end end function questionGen() local questionVar1 = display.newImage("ygSquare.png", 150, 500); local var1 = math.random(1,9) local var1Display =display.newText(var1, 200, 500, native.systemFont, 200) questionVar1.width = 200 questionVar1.height = 200 questionVar1.x = 350 questionVar1.y = 500 var1Display.x = 350 var1Display.y = 500 var1Display:setTextColor("#000000") local questionVar2 = display.newImage("blueSquare.png", 150, 500); local var2 = math.random(1,9) local var2Display = display.newText(var2, 200, 500, native.systemFont, 200) questionVar2.width = 200 questionVar2.height = 200 questionVar2.x = 700 questionVar2.y = 500 var2Display.x = 700 var2Display.y = 500 var2Display:setTextColor("#000000") local operator = " + " local operatorDisplay = display.newText(operator, 400, 500, native.systemFont, 200) operatorDisplay:setTextColor("#000000") local varAnswer = var1 + var2 return varAnswer end