From 6e605673f0c8ed8a9c40e35ad01c920557666ca5 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Wed, 24 Jan 2018 13:02:07 +0200 Subject: [PATCH] Add findLastIndex, update findLast --- snippets/findLast.md | 2 +- tag_database | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/snippets/findLast.md b/snippets/findLast.md index 901920049..00263354a 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.slice(-1)` to get the last one. ```js -const findLast = (arr, fn) => arr.filter(fn).slice(-1); +const findLast = (arr, fn) => arr.filter(fn).slice(-1)[0]; ``` ```js diff --git a/tag_database b/tag_database index 78f14816c..b54055999 100644 --- a/tag_database +++ b/tag_database @@ -53,6 +53,7 @@ fibonacci:math,array filterNonUnique:array findKey:object,function findLast:array +findLastIndex:array,function findLastKey:object,function flatten:array flip:adapter,function