Workshop › Blackjack › Step 9 of 22

Aces: 11 or 1

What we are doing

Going over 21 is a bust, so an ace that would cause it counts 1 instead of 11. As long as the total is over 21 and an ace still counts 11, we take 10 off.

```js
// Aces count 11, unless that would bust the hand: then they count 1.
  while (total > 21 && aces > 0) {
    total -= 10
    aces -= 1
  }
```

What it means

Your turn

  1. Above handValue, write the comment.
  2. Before return total, write the while loop.

Skills: 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