From f8325eabd82d2a9cb3749e775422f08d174dbb5d Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Wed, 11 Dec 2019 09:52:33 +0200 Subject: [PATCH] Update last.md --- snippets/last.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/snippets/last.md b/snippets/last.md index fc1aaed07..bf61f2491 100644 --- a/snippets/last.md +++ b/snippets/last.md @@ -5,9 +5,7 @@ tags: array,beginner Returns the last element in an array. -Check if `arr` is truthy and has a `length` property, use `arr.length - 1` to -compute the index of the last element of the given array and returning it, -otherwise return `undefined` +Check if `arr` is truthy and has a `length` property, use `arr.length - 1` to compute the index of the last element of the given array and return it, otherwise return `undefined`. ```js const last = arr => (arr && arr.length ? arr[arr.length - 1] : undefined);