Tell us what’s happening:
I have completed the half of the challenge. The other half I got stuck of it
What are the mistakes on my code. What is the steps to correct my mistakes and return as below:
findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; });
Your code so far
function findElement(arr) {
for (let num = 0; num < arr.length; num++) {
if (arr[num] % 2 === 0) {
return arr[num];
}
else {
return undefined;
}
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:83.0) Gecko/20100101 Firefox/83.0
.
Challenge: Finders Keepers
Link to the challenge: