View Single Post
Old 09-23-2012, 09:18 AM   PM User | #1
qwertyoone
New to the CF scene

 
Join Date: Sep 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
qwertyoone is an unknown quantity at this point
Unhappy Sum of same variables in a repeated function

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction3()">Click here to start le quiz</button>
<p id="q"></p>
<script>
function myFunction3()
{
var x=Math.floor((Math.random()*12)+1);
var y=Math.floor((Math.random()*12)+1);
var score;
var attempt;
var Tattempt=sum(attempt)

if (Tattempt<11)
{
prompt(x + "x" + y + "=?","");
var name=prompt(x + "x" + y + "=?","");
if (name=x*y)
{
score=1;
attempt=1;
}
else if (name!=x*y)
{
score=0;
attempt=1;
}
else
{
var z="You've got" + sum(score) + "Out of 10!";
document.getElementById("q").innerHTML=z
}
}
}
</script>
</body>
</html>

____________________________________________________________
1. Please state any errors in this code. (If any)
2. I want to create a math quiz on multiplication using JavaScript. Questions are to be randomly generated and separately displayed in a prompt box. The user must recieve a score out of ten. A prompt box for the result is optional.

Last edited by qwertyoone; 09-23-2012 at 09:24 AM..
qwertyoone is offline   Reply With Quote