Tell us what’s happening:
can someone please help explain why my code doesn’t work. I couldn’t really understand the explanation and the way it used num/function. thank you!
Your code so far
function findElement(arr, func) {
let num = 0;
for (var i = 0; i <= arr.length; i++)
if (arr[i] % 2 === 0){
return arr[i];
} else if (arr[i] % 2 != 0){
return undefined
}
// return num;
}
console.log(findElement([1, 2, 3, 4], num => num % 2 === 0));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36
.
Challenge: Finders Keepers
Link to the challenge: