I am currently trying out different methods of solving Finders keepers algorithm. As of late i cannot return the index if func does pass as true with some javascript method.
Here is my code thus far.
function findElement(arr, func) {
let num = 0;for(let i = 0;i <arr.length;i++){
if(arr.some(func) === true){
num = arr[i];
}
}
return num;
}
findElement([1, 2, 3, 4], num => num % 2 === 0);
Thank you in advance for any help with above mentioned problem.