Workshop › 2048 › Step 12 of 26
A move slides every row of the board with slideRow and then adds a new tile. We start with left only; direction
is there for the others.
```js
function move(direction) {
for (let i = 0; i < SIZE; i++) {
const line = board[i]
const { row } = slideRow(line)
board[i] = row
}
addTile()
}
```i, slideRow gives back a new row, which replaces the old one in the board.const { row } = ... takes the row property out of the returned object into a variable of the same name
(object destructuring).Write move above function cellX(col) {, with an empty line after it.
Skills: Functions
← Merge equal tiles The arrow key →