Files
30-seconds-of-code/snippets/last.md
2017-12-27 16:27:06 +02:00

14 lines
230 B
Markdown

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