Files
30-seconds-of-code/snippets/last-of-list.md

156 B

Last of list

Use arr.slice(-1)[0] to get the last element of the given array.

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