This is a simple web-based Blackjack game built using HTML, CSS, and JavaScript. The game allows you to draw cards and try to reach a sum of 21 without going over, aiming to hit Blackjack.
You can play the Blackjack game live here.
Clone the repository to your local machine.
Open the index.html
file in your web browser.
Click "START GAME" to begin. Two random cards will be drawn, and their sum will be displayed.
Click "NEW CARD" to draw additional cards, aiming to reach a sum of 21.
The game will automatically notify you if you win (hit 21) or lose (exceed 21).
The HTML file provides the structure for the game, including headings, buttons, and sections to display messages, cards, and the sum.
The CSS file is responsible for styling the game interface:
The JavaScript file contains the core functionality of the game:
getRandomCard()
: Draws a random card with values between 1 and 11.startGame()
: Initializes the game by drawing two cards and calculating their sum.renderGame()
: Updates the display with the current cards and sum, and checks win/loss conditions.newCard()
: Allows the player to draw an additional card if the game is still active.index.html
: Main HTML file.index.css
: CSS file for styling.index.js
: JavaScript file for game logic.This project is open-source and available under the MIT License.
Enjoy playing the Blackjack game! Feel free to explore, modify, and enhance the code.