Code works fine in console (https://repl.it/@cubefox/-2) but somehow on freecodecamp my answer gets rejected… any Ideas why?
Your code so far
function findElement(arr, func) {
for(i of arr){ if(func(i)) return i; }
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; rv:60.0) Gecko/20100101 Firefox/60.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/finders-keepers