Workshop › Memory › Step 8 of 25
Two small functions turn a card's column and row into pixels: cardX and cardY return the card's left and top
edges, with the formulas from the grid loops.
```js
function cardX(card) {
return GAP + card.col * (CARD + GAP)
}
function cardY(card) {
return TOP + GAP + card.row * (CARD + GAP)
}
```card is a parameter: the card object given to the function.return gives the computed number back to whoever called the function.Under newGame, write cardX and cardY with empty lines between them. Press Run.
Skills: Functions
← Cards that know themselves Draw the cards from the list →