Workshop › Blackjack › Step 1 of 22
Beat the dealer without going over 21. Cards as objects, a fair Fisher–Yates shuffle, aces worth 11 or 1, a dealer that follows fixed rules, chips and payouts, a turn spread over time, doubling down, and buttons that show what you can do.
We are building Blackjack: get closer to 21 than the dealer without going over. First the pieces: the 13 ranks, the 4 suits, a small function that makes a card object, and a green table.
```js
const canvas = document.getElementById('game')
const ctx = canvas.getContext('2d')
const RANKS = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']
const SUITS = ['♠', '♥', '♦', '♣']
const card = (rank, suit) => ({ rank, suit })
function draw() {
ctx.fillStyle = '#166534'
ctx.fillRect(0, 0, canvas.width, canvas.height)
}
draw()
```RANKS and SUITS are lists of text; the suits are real card symbols.card('K', '♥') makes { rank: 'K', suit: '♥' }. The parentheses around { ... } make the arrow return an object.Write the lines under the comments, then press Run.
Skills: Drawing on a canvas, Arrays and objects