Taken from Execute Program
Use
.findIndex
to write the functionfind(arr, callback)
. It should return the first element wherecallback(element)
istrue
. If the element is not found, it should returnundefined
.
Solution
This is the answer I came up with: