Finders Keepers que

function findElement(arr, func) {
  let num = 0;
  
  for(let i = 0; i < arr.length; i++) {
    if (arr[i] % 2 === 0){
      num = arr[i];
    } else{
      return undefined;
    }
  }
  return num;
}

console.log(findElement([1, 2, 3, 4], num => num % 2 === 0));

This code give only one solution… what should i do?

You are not using func, the callback you should be using to check the elements in the array

But your code does this:

Check first element of the array, if it is even, set num to that element. If it is odd, return undefined (and function stop running), check next element and do the same. At the end, if the function has not already returned something, return num (Which is the last even number in the array)

Is this what the challenge asks from you?

Thanks @ilenia for checking out. I will find it…:slightly_smiling_face: