diff --git a/snippets/findLast.md b/snippets/findLast.md index 1a3ae39b6..911177269 100644 --- a/snippets/findLast.md +++ b/snippets/findLast.md @@ -5,7 +5,7 @@ Returns the last element for which the provided function returns a truthy value. Use `Array.filter()` to remove elements for which `fn` returns falsey values, `Array.pop()` to get the last one. ```js -const findLast = (arr, fn) => arr.filter(fn).slice(-1)[0]; +const findLast = (arr, fn) => arr.filter(fn).pop(); ``` ```js