Workshop › Klondike Solitaire › Step 13 of 40
The first move of the game: take the top card of the stock, turn it face up and put it on the waste. flipStock does
exactly that.
```js
function flipStock() {
if (piles.stock.length) {
const card = piles.stock.pop()
card.up = true
piles.waste.push(card)
}
}
```if (piles.stock.length) is true when the stock has cards (0 counts as false).pop() removes the last card of an array and returns it; push puts it at the end of the waste.Under cardY, leave an empty line and write flipStock. Press Run.
Skills: Arrays and objects, Game states
← Outlines for empty places Space turns a card →