我正在尝试学习 JavaScript,我正在尝试创建一个基本的比较游戏,我将卡号放在一个数组中,我随机调用其中 2 个,并且我想比较 2 个随机调用中的哪一个有更高的价值?请帮我。我已经设法编写程序来随机处理 2 张牌,我只需要有关如何比较抽出的 2 张牌的指导。
谢谢你。
{
// This is my attempt to create a basic game for a simplified version of ta siau
//where players choose a card, and compares it with dealer's card. Bigger card wins the round
var cards = [2,3,4,5,6,7,8,9,10,"jack","queen","king","ace"]; //available cards in the deck
confirm("start game now?");
var playerCard = cards[Math.floor(Math.random() * cards.length)]; //choose a random card for player
console.log(playerCard);
var dealerCard = cards[Math.floor(Math.random() * cards.length)]; //choose a random card for dealer
console.log(dealerCard);
}