Workshop › Memory › Step 7 of 25
A card is more than a fruit: it has a place on the grid and it is face up or not. map turns each fruit into a card
object with those fields.
```js
const deck = [...SYMBOLS, ...SYMBOLS]
cards = deck.map((symbol, index) => ({
symbol,
col: index % SIZE,
row: Math.floor(index / SIZE),
faceUp: false,
matched: false,
}))
```deck.map(fn) makes a new array by running fn on each item: here each fruit becomes a card object.symbol is the fruit, index its position 0 to 15. { symbol } is short for { symbol: symbol }.index % SIZE is the column (the remainder after dividing by 4), Math.floor(index / SIZE) the row.( ) so the braces are not read as a function body.In newGame, replace cards = [...SYMBOLS, ...SYMBOLS] with the new lines. Press Run.
Skills: Arrays and objects, Game states
← Every fruit twice A card's corner →