If I assume OAI already knows the rules of poker and can build a deck of cards then deal them. I can simplify the instruction and save a lot of computation in the process…
/* Create a poker game with 2 players. Each player is dealt 5 cards in a hand. */
javascript:
var deck = [
'2C', '2D', '2H', '2S', '3C', '3D', '3H', '3S', '4C', '4D', '4H', '4S', '5C', '5D', '5H', '5S',
'6C', '6D', '6H', '6S', '7C', '7D', '7H', '7S', '8C', '8D', '8H', '8S', '9C', '9D', '9H', '9S',
'10C', '10D', '10H', '10S', 'JC', 'JD', 'JH', 'JS', 'QC', 'QD', 'QH', 'QS', 'KC', 'KD', 'KH', 'KS',
'AC', 'AD', 'AH', 'AS'
];
var player1 = {
hand: [],
name: 'Player 1'
};
var player2 = {
hand: [],
name: 'Player 2'
};
for (var i = 0; i < 5; i++) {
player1.hand.push(deck.splice(Math.floor(Math.random() * deck.length), 1)[0]);
player2.hand.push(deck.splice(Math.floor(Math.random() * deck.length), 1)[0]);
}