Workshop › Klondike Solitaire › Step 4 of 40
Hearts and diamonds are red. A tiny function isRed answers that question, and the text color comes from it. The rules
will need isRed again later.
```js
const isRed = (card) => card.suit === 1 || card.suit === 2
ctx.fillStyle = isRed(card) ? '#dc2626' : '#0f172a'
```(card) => ... is an arrow function: it takes card and returns the value after =>.|| means "or": suit 1 (♥) or suit 2 (♦) is red.isRed(card) is true, dark otherwise.const CH = 78 leave an empty line and write isRed.drawCardAt, change the line ctx.fillStyle = '#0f172a' (the one after return) as shown.Skills: Functions
← The face of a card A deck of 52 →