Blackjack

A Javascript Browser Game

For this project we were tasked with creating a simple blackjack game that runs in the browser and uses DOM manuipulation to access cards and update scores. Hit and Stand functions enable the player to keep their current cards or end the round. The dealer is programmed to stand when the value of their cards is between 17 and 21. When you or the dealer bust the round ends.

Tenchnologies

Javascript

HTML

CSS

Role

I created the game from start to finish. Code was built starting with assigning value to the cards and then linking the suit and value to the corresponding image file - './image/${rank}_of_${suit}.png'. Next a shuffle function arranges the cards in a random order. A deal function takes the top 4 cards and assigns two each to the player and the dealer. A function to calculate the score based on the cards value runs to let the dealer know wether to hit or stand and to display the player's score. Ace's have their own function to calculate value based on total hand score. The hit function appends another card to the player's hand array. Stand ends the game. Try it out.

cards