hi, im new to javascript and im trying to program a small card memory game. im having troubles with shuffling the cards on startup. can anyone help me do it? thanks
[code]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
“http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<title>Untitled Document</title>
<SCRIPT LANGUAGE=”JAVASCRIPT” TYPE=”TEXT/JAVASCRIPT”>
<!–
var cards = new Array(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8); //fill the cards array with unshuffled pair numbers
var matched = new Array(16);
var clicked = 0;
var matchCount = 0;
var firstCard;
var pair;
shuffle(cards); //call the shuffle function
function shuffle(deck)
{
}
function turnOver(e)
{
if (matchCount<8 & !matched[e.name])
{
if (clicked<1)
{
firstCard=e; //grab first card object
pair=cards[firstCard.name]; //get first pair number from cards array
e.src=document.images[“load”+pair].src; //flip over first card
clicked++;
}
else
{
e.src=document.images[“load”+cards[e.name]].src; //flip over second card
if (pair!==cards[e.name])
{ //check for snap
alert(“That’s not a match, try again!”);
firstCard.src=document.images[“load0”].src; //flip first card back
e.src=document.images[“load0”].src; //flip second card back
}
else
{
//This is a match so record matched cards and increase matchCount
matched[firstCard.name]=true;
matched[e.name]=true;
matchCount++;
}
clicked=0;
}
}
}
//–>
</SCRIPT>
<style type=”text/css”>
<!–
body
{
background-color: #FFFFFF;
}
body,td,th
{
font-family: Verdana, Arial, Helvetica, sans-serif;
}
–>
</style>
</head>