Workshop › Blackjack › Step 4 of 22

Deal

What we are doing

You and the dealer each get two cards from the top of the deck. The top is the end of the list: pop takes it off.

```js
let player
let dealer

const nextCard = () => deck.pop()

function deal() {
  player = [nextCard(), nextCard()]
  dealer = [nextCard(), nextCard()]
}

deal()
```

What it means

Your turn

  1. Under deck, write player and dealer.
  2. Under newDeck, write nextCard and deal.
  3. At the bottom, call deal() after newDeck().

Skills: Arrays and objects, Functions

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