View Single Post
Old 12-04-2012, 07:53 AM   PM User | #18
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,035
Thanks: 197
Thanked 2,410 Times in 2,388 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
You don't need images - you could use the HTML codes.
&hearts &clubs &diams &spades


Shuffle is probably a bit advanced for you at this stage, but

Code:
<script type = "text/javascript">
var imgArray = new Array('Ace',2,3,4,5,6,7,8,9,10,'Jack','Queen','King'); 

Array.prototype.shuffle = function() {
var s = [];
while (this.length) s.push(this.splice(Math.random() * this.length, 1));
while (s.length) this.push(s.pop());
return this;
}

imgArray.shuffle();
var card1 = imgArray[0];
alert (card1);
imgArray.shuffle();
var card2 = imgArray[0];
alert (card2);

if (card1 == card2) {
alert ("The cards match!");
}
</script>
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 12-04-2012 at 08:16 AM..
Philip M is online now   Reply With Quote