Finders Keepers - map function

Tell us what’s happening:

Figured this with a for loop, but wondering why this won’t also work?

Your code so far


function findElement(arr, func) {
  arr.map((num) => {
    return func(num) ? num : undefined;
  });
  return undefined;
}

findElement([1, 3, 5, 8, 9, 10], num => num % 2 === 0);

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/finders-keepers

Your code always returns undefined. You must return the first element than passes the tests.

This return is inherent at map function. This line arr.map(yourFunction) returns a array of lengt of arr. But this is not returned by findElement