Workshop › Chess › Step 15 of 48
When a piece is picked up, keep its moves in targets: all the moves of the side to move, filtered to those that
start on the selected square.
```js
let targets // the moves of the selected piece
targets = []
selected = [r, c]
targets = pseudoMoves(turn).filter((m) => same(m.from, selected))
} else {
selected = null
targets = []
}
```targets starts as an empty list.filter keeps the items for which the function returns true: here, the moves whose from is the selected square.targets.let selected ... write let targets ...; in reset, under selected = null write targets = [].clickSquare, add the two targets lines.Skills: Arrays and objects
← Whose turn is it? Show the targets →