Tell us what’s happening:
Your code so far
function findElement(arr, func) {
for (let num = 0; num < arr.length; num++)
if (func(arr[num]))
return arr[num];
return undefined;
}
findElement([3, 3, 3, 1], num => num % 2 === 0);
FCC forces you to use the num variable as they’ve initialized even though my solution here works perfectly in console without it.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
.
Link to the challenge:
javascript-algorithms-and-data-structures/basic-algorithm-scripting/finders-keepers]