I'm trying to learn about JavaScript, and I'm trying to create a basic comparison game, where I place card numbers in an array, I call 2 of them randomly, and I want to compare which one of the 2 random calls has higher value? Please help me. I've managed to code the program to deal 2 cards at random, I just need a guidance on how to compare the 2 cards drawn.
Thank you.
{
// 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);
}
player > dealerwithplayer >= dealerif the player wins if it's a draw