Build a First Element Finder - Build a First Element Finder

Tell us what’s happening:

Had no idea on how to solve this problem. And little assistance would be appreciated

Your code so far

const findElement=(arr,x)=>
{
for(const elem of arr){
  x(elem)
}
return undefined
}

let res=findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; })

console.log(res)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Build a First Element Finder - Build a First Element Finder

Welcome to the forum @karthick96!

Currently your function only returns undefined, because this is the only return in your code. So you have to find a way to return the solution differently.

If a function doesn´t return anything, it will automatically return undefined, when called.

I wish to ask you, why you put x as a second argument to your function?

You seem to have the right idea since your function starts by looping over the array. But what do you need to do inside the loop to see if an array element returns true from the function argument?