Hello,
Do you have any idea for how my code can return 8 and not 10? My loop finish at 10, how can I have 8?
Thnx a lot for help.
function findElement(arr, func) {
let num = 0;
for(let i=0; i < arr.length; i++) {
if(func) {
num = arr[i];
}else{return undefined}
}
return num;
}
findElement([1, 2, 3, 4], num => num % 2 === 0);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/finders-keepers