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