# Homeyscrip findLast() doesn't work

**URL:** <https://community.homey.app/t/homeyscrip-findlast-doesnt-work/75090>\
**Category:** Developers\
**Created:** [January 14, 2023, 5:35pm UTC](https://community.homey.app/t/homeyscrip-findlast-doesnt-work/75090 "2023-01-14T17:35:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 14, 2023, 5:35pm UTC](https://community.homey.app/t/homeyscrip-findlast-doesnt-work/75090/1 "2023-01-14T17:35:39Z")

</div>

```auto
const array1 = [5, 12, 50, 130, 44];

const found = array1.findLast((element) => element > 45);

console.log(found);

i want to find a number, from the last index on to the first index. Copied this from the internet but it doesn't work. 

```

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [January 14, 2023, 5:41pm UTC](https://community.homey.app/t/homeyscrip-findlast-doesnt-work/75090/2 "2023-01-14T17:41:23Z")

</div>

The Node.js version that Homey runs is too old, but you can use this:

```auto
const found = [...array1].reverse().find(element => element > 45);

```

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 14, 2023, 6:55pm UTC](https://community.homey.app/t/homeyscrip-findlast-doesnt-work/75090/3 "2023-01-14T18:55:19Z")

</div>

> [@robertklep](#):
>
> `const found = [...array1].reverse().find(element => element > 45);`

thx Robert works perfect!!

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [January 14, 2023, 8:56pm UTC](https://community.homey.app/t/homeyscrip-findlast-doesnt-work/75090/4 "2023-01-14T20:56:47Z")

</div>

Lodash is also available right?  
So you can also use `_.last(arr, element => element > 45)`

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 15, 2023, 3:43am UTC](https://community.homey.app/t/homeyscrip-findlast-doesnt-work/75090/5 "2023-01-15T03:43:42Z")

</div>

I will take a look. Lodash is unknown to me. But the first peek looks promising. Thx Arie.
