Tell us what’s happening:
Can’t understand why in this challenge it is asked to return 8, while 10 is also true for given function…
Is it a bug, or peculiarity of forEach()method?
Your code so far
function findElement(arr, func) {
arr.forEach(function(element){
if(func(element)== true){
return element;
} else {
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) 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/