Tell us what’s happening:
I’m trying to loop through the array and test each item in the array to see if it returns a truthy value if passed onto the function func. The test array [1, 3, 5, 8, 9, 10] is not returning the value 8 as expected. Anyone to help identify where I got it all wrong?
**Your code so far**
function findElement(arr, func) {
arr.map(item =>{
if (func(item)){
return item;
}
});
return undefined;
}
findElement([1, 2, 3, 4], num => num % 2 === 0);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36.