Javascript Blackjack Dealer
- Javascript Blackjack Dealer Login
- Javascript Blackjack Dealers
- Javascript Blackjack Dealer Portal
- Javascript Blackjack Dealer Log
- I'm having trouble creating a Blackjack program to display in an HTML page using an external Javascript file. I don't need to label my cards, and I've created a dealer that will always be between 17-21 in score. I'm unsure of what parts of my code is completely wrong and what needs a bit of tweaking.
- This is the first video in my 'Let's Code' series. If you enjoyed it, please let me know, I plan to do plenty more of these in the future!
Looking for a new project in JavaScript that I have not done in Python, I got to thinking about arrays.
Here's a fun and simple blackjack game I built using HTML5, CSS and JQuery. I'd like to add more features to it like betting, splitting and doubling down and it's on github so anyone can add to it. Follow the link below to play! // Reset $ ('.dealer-cards'). Blackjack Rules Object. Blackjack is a betting game played against a dealer. The object is score more points than the dealer without going over 21. Points are totaled for each card in a hand. Face cards (Jack, Queen and King) count as 10 points, Aces may be counted as either one or 11.
As JavaScript allows us to generate random numbers and store variables (see “Scissor, Paper, Stone”) it should allow me to also recreate the card game of Blackjack or 21. For more information on Blackjack please see: https://en.wikipedia.org/wiki/Blackjack
The smallest game of Blackjack requires 2 people – a player and a dealer.
The objective of Blackjack is for the player to either score 21 with 2 cards, or get a higher score than the dealer without going over 21. If the player goes over 21 then they lose. If the dealer goes over 21 then the banker loses.
The dealer is going to be controlled by the computer.

I’m going to use one deck of cards (52 cards). The 52 cards are split into 4 suites (Hearts, Diamonds, Spades, Clubs) with each suite containing 13 cards:
Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King
For this version of Blackjack I’m going to define an Ace as having the value of 1, and the Jack, Queen, King as having the value of 11.
So each suite now has;
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 11, 11
The values can be stored in an array, which we can call “deck”:
// variable to hold the deck of 52 cards
var deck = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11];
We then need JavaScript to randomly choose a card and remove the card from the possible cards that can be played.
// geektechstuff
// BlackJack
// variable to hold the deck of 52 cards
var deck = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11];
// variable to choose a random card from the deck
var card = deck[Math.floor(Math.random()*deck.length)],
card_remove = card,
position = deck.indexOf(card);
if (~position) deck.splice(position, 1);
// checking that a card is picked and that it is removed from deck
Javascript Blackjack Dealer Login
console.warn(card)
console.warn(deck)
Next up I will need to look at storing the card values in the players hand or the dealers hand and checking if the values have gone over 21.
Javascript Blackjack Dealers
Blackjack
Description: Very simple JavaScript which simulates a game of Blackjack. |
JavaScript Functions:
Javascript Blackjack Dealer Portal
HTML Script:
Javascript Blackjack Dealer Log
—
more Scripts: Alerts, Forms, Text, Buttons, Games, User Information, Calendars, Miscellaneous, Utilities,
Clocks, Navigation, Windows, Cookies, Page Information, Special Effects, Counters, Passwords, DHTML
[Home] [Templates] [Blog] [Forum] [Directory] JavaScript - Blackjack