Workshop › 2048 › Step 15 of 26
Do we need a second function for right? No: reverse the row, slide it left, reverse it back. Sliding a reversed row left is the same as sliding the original row right.
```js
const reversed = direction === 'right'
const line = [...board[i]]
if (reversed) line.reverse()
const { row } = slideRow(line)
if (reversed) row.reverse()
const directions = { ArrowLeft: 'left', ArrowRight: 'right' }
```reversed is true for right.reverse() turns an array around in place: it changes the array itself. So we reverse a copy: [...board[i]]
spreads the row's items into a new array.move, under before, write the reversed line.line to a copy and add the two reverse lines.ArrowRight to the table.Skills: Arrays and objects
← Only real moves count Up and down are columns →