Finders Keepers Question

Here is my code :

function findElement(arr, func) {

  for(let i=0;i<arr.length;i++){
    let num=arr[i];
    if(func===true){ //I think this part is not correct
      return arr[i];


console.log(findElement([1, 2, 3, 4], num => num % 2 === 0));

So, my thought process is this,

  1. assign each arr elements into num so that func knows what to use
  2. if func returns true, it will return the exact arr[i] then the for loop ends.

Is my logic correct?
If it is, how to write code to check whether func returns true?
If it is not, which part of it is wrong?

func is a function. How you you call a function and pass it a value?



or should I use ?

Yes, but if I want to pass a value to the function like the number 2 or a variable, how would you do that?


provided that there is only one variable in the function

Yes, so in the challenge you are supposed to call func using num as it’s argument.

so in order to check whether the function returns true, you just need to execute it?

Yes, but just make sure you pass num as the argument to the function.

1 Like

i see. thanks.

also how do I add spoiler too multiple lines of code?
i just add the spoiler tag every line or ?

No, you just put the opening tag on a separate line and put all the lines of code you want after it and then put the closing tag below the code you want to hide.


// line of code
// line of code
// line of code


1 Like