having abit of trouble with this code here is wot i want to do but dont seem to be working like that can someone help please..
thanks
Promt the user to answer the 10 questions, record the answers and compare them to the correct answers. Once the user has answered all 10 questions, display on the page each question, the users's answer and a message saying whether the answer was correct or not. In case of incorrect answer, also display the correct answer.
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<style>
</style>
</head>
<body>
<h1><font color="blue">Maths Game</h1></font>
<script type="text/javascript">
var ua = new Array();
var ca = new Array();
var xa = new Array();
var ya = new Array();
var opa = new Array();
var dispa = new Array();
var ops = ["+","-","*"];
function showResult()
{
var cnt = dispa.length;
for(var i=0;i<cnt;i++)
{
document.write("<br />"+dispa[i]+ " = " + ua[i]);
if(ua[i]!=ca[i])
{
document.write(" is incorrect - <span style='color:red'>The correct answer is " + ca[i] + "</span>");
}
else
{
document.write(" <span style='color:green'>The answer is correct</span>");
score += 2;
}
}
ua = new Array();
ca = new Array();
xa = new Array();
ya = new Array();
opa = new Array();
dispa = new Array();
}
for(var i=0;i<10;i++)
{
var x = Math.floor(Math.random()*101);
var y = Math.floor(Math.random()*101);
if(x<y)
{
var temp = x;
x = y;
y = temp;
}
xa.push(x);
ya.push(y);
op = ops[Math.floor(Math.random()*ops.length)];
var disp = x +" "+op+" "+y;
dispa.push(disp);
var v = prompt("How much is " + disp + " ?");
ua.push(v);
ca.push(Math.round(eval(disp)));
showResult();
}
var score = 0;
document.write("<br />Your score: " + score);
if(score<10) document.body.style.backgroundColor='red';
</script>
</body>
</html>