|
If you want to adopt an object oriented approach you could create a javascript deck of cards object with a property being an array of the cards and then object methods to deal and shuffle the cards. The method to deal the cards would generate a random number from 0 to the number of cards left in the deck -1 and then remove the card at that random number index in the cards array as it is "dealt" to a player.
Using an object oriented approach then allows you to use that deck of cards object in other javascript applications very easily.
|