Have a look at my solution using find()
in your other post to find the first matching element in an array. Make sure you understand how that works (ask there for help if you can't understand it after looking at the docs for Array.find()
) and then have a go at solving this problem using findLast()
which is exactly the same as find()
except that it finds the last matching instead of the first.