Files
30-seconds-of-code/snippets/last.md
2017-12-17 17:55:51 +02:00

11 lines
218 B
Markdown

### last
Returns the last element in an array.
Use `arr.length - 1` to compute index of the last element of the given array and returning it.
```js
const last = arr => arr[arr.length - 1];
// last([1,2,3]) -> 3
```