Taken from Execute Program
Use
.findIndexto 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:
function find(arr: Array<any>, callback: any) {
let index = arr.findIndex(callback)
return ( index >= 0 ) ? arr[index] : undefined
}