Why can’t I include an else statement without conditions to the finders keepers challenge.
Why wouldn’t this work:
function findElement(arr, func) {
let num = 0;
for(var i=0; i<arr.length;i++){
num= arr[i];
if (func(num)){
return num
}
else{
return undefined
}
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
.
Challenge: Finders Keepers
Link to the challenge: