Hello,
I'm creating a blackjack game,and would like the function cardToString to return the file name of a card e.g "AceDiamonds.gif" and fill an array called deck,its only returning one card and not filling the array
thank you in advance
<script>
var dealer_hand = new Array();
var player_hand = new Array();
var deck = [52];
function cardToString(value,suit)
{
var cvalue="";
var csuit="";
switch(value)
{
case 1:
cvalue = "Ace";
break;
case 2:
cvalue = "Two";
break;
case 3:
cvalue = "Three";
break;
case 4:
cvalue = "Four";
break;
case 5:
cvalue = "Five";
break;
case 6:
cvalue = "Six";
break;
case 7:
cvalue = "Seven";
break;
case 8:
cvalue = "Eight";
break;
case 9:
cvalue = "Nine";
break;
case 10:
cvalue = "Ten";
break;
case 11:
cvalue = "Jack";
break;
case 12:
cvalue = "Queen";
break;
case 13:
cvalue = "King";
break;
default:
cvalue=null;
break;
}
switch(suit)
{
case 1:
csuit="Clubs";
break;
case 2:
csuit="Hearts";
break;
case 3:
csuit="Diamonds";
break;
case 4:
csuit="Spades";
break;
default:
csuit=null;
break;
}
if(value==null||suit==null)
return"";
var myCard = cvalue + csuit +".gif";
return myCard;
}//End of cardToString Function
function shuffle()
{
for(var i=0;i<deck.length;i++)
{
var num1 = Math.floor(Math.random()* 13)+1;
var num2 = Math.floor(Math.random()* 4)+1;
myCard = cardToString(num1,num2);
deck[i] = myCard;
}
alert(deck);
}
</script>
<input type=button value="Shuffle" onclick="shuffle()"/>
</body>
</html>