Workshop › Blackjack › Step 2 of 22

A deck

What we are doing

A deck has one card of every rank in every suit: 4 × 13 = 52. Two loops, one inside the other, make them all.

```js
let deck

function newDeck() {
  deck = []
  for (const suit of SUITS) for (const rank of RANKS) deck.push(card(rank, suit))
}

newDeck()
```

What it means

Your turn

  1. Under SUITS, write let deck (with an empty line before and after it).
  2. Under card, write newDeck.
  3. At the bottom, call newDeck() above draw().

Skills: Arrays and objects, Loops

All steps

  1. Cards
  2. A deck
  3. Shuffle
  4. Deal
  5. Cards on the table
  6. Card faces
  7. Keep drawing
  8. What is a hand worth?
  9. Aces: 11 or 1
  10. Hit: one more card
  11. Stand
  12. The hidden card
  13. Chips
  14. Who wins?
  15. The dealer's turn
  16. The next round
  17. Blackjack!
  18. Your record
  19. Double down
  20. Long hands fit
  21. Buttons
  22. Build it yourself: six decks