Files
30-seconds-of-code/snippets/last-of-list.md
Stefan Feješ b848906fe5 fix naming
2017-12-17 15:41:31 +01:00

194 B

Last of list

Use arr.length - 1 to compute index of the last element of the given array and returning it.

const lastOfArray = arr => arr[arr.length - 1];
// last([1,2,3]) -> 3