T
tofu12
Hello I am trying to shuffle a deck of 25 cards and have the user
select five random cards after the shuffle. On choosing the cards they
turn over displaying the card image. The cards are shuffling, but when
the user attempts to choose five cards only three or two of the card
images appear. Can someone help here?
Code submitted below
var Thumbimgs="images/thumbs/";
var NumOfCards=25;
var count=0;
var CardsInSpread=5;
SelectedCards=new Array();
function Selected(CardPosition, CardNumber)
{
var CardNumber= Math.round((NumOfCards-1)*Math.random());
if (count < CardsInSpread) {
for (var i = 0; i <= NumOfCards; i++)
{
if (SelectedCards == CardNumber) {return;}
}
SelectedCards[count] = CardNumber;
count=count+1;
document.images[CardPosition+1].src = Thumbimgs + CardNumber
+ ".gif";
}
}
select five random cards after the shuffle. On choosing the cards they
turn over displaying the card image. The cards are shuffling, but when
the user attempts to choose five cards only three or two of the card
images appear. Can someone help here?
Code submitted below
var Thumbimgs="images/thumbs/";
var NumOfCards=25;
var count=0;
var CardsInSpread=5;
SelectedCards=new Array();
function Selected(CardPosition, CardNumber)
{
var CardNumber= Math.round((NumOfCards-1)*Math.random());
if (count < CardsInSpread) {
for (var i = 0; i <= NumOfCards; i++)
{
if (SelectedCards == CardNumber) {return;}
}
SelectedCards[count] = CardNumber;
count=count+1;
document.images[CardPosition+1].src = Thumbimgs + CardNumber
+ ".gif";
}
}