/    Sign up×
Community /Pin to ProfileBookmark

undefined element

i have a proble look at this and let me know why the first digit that you insert comes out as undefined please , this is driving me insane!!!!
what i’m trying to do is :
1) make the game generate randoms numbers (4)and
2) make the user inout his numbers (4)

var myPegs = new Array ()

window.prompt(“how many pegs do you want to play with?”,””);

function myPegs (gamennr)

{

for (i=0; i<4; i++)

gamennr[i]=Math.floor(Math.ramdom*6)+1;

}

document.writeln( “<table border = “1”” + “width = “100%”>”);
document.writeln( “<thead><th width = “100”” + “align = “left”>the game numbers<th align = “left”>” + “your numbers<th align = “left”>” + “right number, wrong place<th align = “left”>”+ “right number, right place<th align = “left”>”+”number of attemps</th></thead></tbody>”);

for (i=0; i<4;i++){

document.writeln( “<tr><td>” + gamennr[i]+”</td><td>” + x + “</td></tr>”);

var x = 4
window.prompt ( “please enter the digit”);

}

function counter (){

if ( x=myPegs )
window.alert ( “you won the game”);
else
{
document.writeln (“you have right numbers in the wrong place “);
}
}

//–>
</script>
</HEAD>

<BODY>
<script>
<h3>Master Mind</h3>

var gamennr= new Array(4);
myPegs (gamennr)
</script>
</BODY>
</HTML>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@WebskaterJan 26.2003 — gamennr[i]=Math.floor(Math.ramdom*6)+1;



You have a typo there I think. Shouldn't it say Math.random
×

Success!

Help @nicoletta spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...