JavaScript submit button

Hi,

Its nice to be back!!! Anyway I’ve recently started moving into JavaScript and I’ve made a simple game to get me started. It gives you three numbers of a sequence and you work out the fourth (it’s for kids) when you get it right it said “right” and vice versa.

**All I need help with is the answer input. I realize you need a form box, but the submit script and the rest is a bit of a mystery to me. I know I will need an if statement somewhere saying if the answer they give is equal to the answer I give, say “true”.

**My code so far;


<body>
<script type="text/javascript">
var a;
var b;
var c;
var ans;
var ran;

ran=Math.floor(Math.random()*11);
a=Math.floor(Math.random()*11);
b=a+ran
c=b+ran
ans=c+ran

document.write(a);
document.write("<br>");
document.write(b);
document.write("<br>");
document.write(c);
document.write("<br>");
document.write("<button onClick='{alert(ans);}'>cheat</button>");
</script>
</body>