JSFiddle - React, Tailwind, and code Playground
by Dwza
HTML
<body>
<p id="playerCards"></p>
<p id="dealerCards"></p>
<form id="betForm">
How much would you like to bet?<input type="text" name="betAmount">
</form>
<button onclick="newGame()">New Game</button>
<button onclick="playerDraw()">HIT</button>
<button onclick="stand()">STAND</button>
<p id="shuffle"></p>
<p id="gameStatus"></p>
</body>
JavaScript
var a=0;//variable borrowed for use in a few of the functions
var deck=[1,2,3,4,5,6,7,8,9,10,10,10,10,1,2,3,4,5,6,7,8,9,10,10,10,10,1,2,3,4,5,6,7,8,9,10,10,10,10,1,2,3,4,5,6,7,8,9,10,10,10,10];//the number value of each card in the deck
var deckSuits=["a","a","a","a","a","a","a","a","a","a","a","a","a","b","b","b","b","b","b","b","b","b","b","b","b","b","c","c","c","c","c","c","c","c","c","c","c","c","c","d","d","d","d","d","d","d","d","d","d","d","d","d"];//symbols to represent the suit of each card
var deckMedianL=0;//a variable used to determine the median value of the deck
var deckMedianR=0;//a variable used to determine the median value of the deck
var deckMedian=0;//variable set to the median of the deck in the function stand
var x=0;//variable used in a few functions to find the length of deck
var balance=200;
var bet=0;
alert(deck);
function newGame()
{
alert(document.deck);
var playerValue=0;//total value of the cards in the players hand
var dealerValue=0;//total value of the cards in the dealers hand
var game=0;//variable used to decide if the game was a win, loss, or draw
document.getElementById("playerCards").innerHTML="Your cards are:";//tells the player that they have no cards
document.getElementById("dealerCards").innerHTML="Dealers cards are:";//tells the player that the dealer has no cards
document.getElementById("gameStatus").innerHTML="";//sets the innerHTML of gameStatus to "" so that it doesn't say win/loss/draw until one of those status's are applicable
document.getElementById("shuffle").innerHTML="";//sets shuffle to "" so that if the deck was just shuffled it would not appear to the player that it just got shuffled...