Tell us what’s happening:
I’m coming back after a while so I am a bit rusty.
Can anyone let me know what I am doing wrong?
Your code so far
function test(arr){
for(let i=0;i<arr.length;i++){
if(arr[i]%2==0){
return arr[i]
}
}
return undefined
}
function findElement(arr,func){
return func(arr);
}
console.log(findElement([1,2,3,4],test));
console.log(findElement([1,3,5,9],test))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36 Edg/152.0.0.0
Challenge Information:
Build a First Element Finder - Build a First Element Finder
GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-first-element-finder/a6e40f1041b06c996f7b2406.md at main · freeCodeCamp/freeCodeCamp · GitHub
Teller
2
Hi @User_9621
You need to use the test function supplied.
findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; })
Happy coding
ILM
3
this function seems to be returning the output of the test function on the whole array, are you srue this is what is being asked for?
in your understanding, what is your goal in this lab?
I did this late and only realised I was doing something else after waking up.
Thanks for the help.
Thanks for the help.
I was really sleepy while working on this.
My bad 