Finders Keepers - func is not evaluated

Tell us what’s happening:

Can’t figure out why this condition if (, arr[i])) is not being evaluated to true or false inside the statement, even though when I console.log it I’m getting true of false on each array element…

Your code so far

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

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36.

Link to the challenge:

func actually gets evaluated, but the problem is that your if-else block both returns. This breaks the for-loop right after checking the first array value, without checking the rest of the values.

You probably don’t want to return undefined right when the function call returns false, but rather after making sure that all the array values have been evaluated.

Yes, that’s it! Thank you!
Just had to move the undefined outside the for loop