here we are again, i have almost completed the script but it is not working properly. what it does it : the game produced randoms numbers, the user imput numbers and th egame has to compare them and tell the user that 1) if the user imput the same number there is an alert saying you won and if the numbers are different there is an alert saying try again
I have written the program so that you can actually see what numbers the computer generates to make it easier for testing but i don't understand why it doesn't work properly
can you help
this is the script
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<H3>MasterMind</H3>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="Javascript">
<!--
function SymError ()
{
return true;
}
window.onerror = SymError;
var gameNumber = new Array ()
var size = prompt (" how many number do you want to play with?","")
document.writeln ("you want to play with " + size +" numbers");
for (i=0 ; i<size ; i++)
{
gameNumber = Math.floor(Math.random () *6 )+1;
}
document.writeln ( "<br>these are the game numbers " + gameNumber + "</br>");
var userInput ;
for (j = 1; j <=size;j ++)
{
var userInput = window.prompt ("please enter a digit from 1 to 6","");
{
document.writeln ("guess "+ userInput);
}
}
var n = 0
for (n=0; n<size; n++)
{
if (userInput[n] == gameNumber[n])
window.alert("Congratulations");
else {
window.alert("Better luck next time");
}
}
-- >
</script>
</HEAD>
<BODY>
</BODY>
</HTML>
I have written the program so that you can actually see what numbers the computer generates to make it easier for testing but i don't understand why it doesn't work properly
can you help
this is the script
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<H3>MasterMind</H3>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="Javascript">
<!--
function SymError ()
{
return true;
}
window.onerror = SymError;
var gameNumber = new Array ()
var size = prompt (" how many number do you want to play with?","")
document.writeln ("you want to play with " + size +" numbers");
for (i=0 ; i<size ; i++)
{
gameNumber = Math.floor(Math.random () *6 )+1;
}
document.writeln ( "<br>these are the game numbers " + gameNumber + "</br>");
var userInput ;
for (j = 1; j <=size;j ++)
{
var userInput = window.prompt ("please enter a digit from 1 to 6","");
{
document.writeln ("guess "+ userInput);
}
}
var n = 0
for (n=0; n<size; n++)
{
if (userInput[n] == gameNumber[n])
window.alert("Congratulations");
else {
window.alert("Better luck next time");
}
}
-- >
</script>
</HEAD>
<BODY>
</BODY>
</HTML>