Basic Algorithm Scripting: Finders Keepers**


How may I use the function in the argument? I need to apply in order to pass the challenge.

function findElement(arr, func) {
        
        for (let i=0;i<arr.length;i++){
                
            let num=arr[i];

               if (func==0){
                   
                   return num; 
               }else {
          
                   return undefined;
               }
        }


}

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

Thanks for your time!

function findElement(arr, func) {
        
        for (let i=0;i<arr.length;i++){
                
            let num=arr[i];

               if (func(num)){
                   
                   
                   return num; 
              
              
               }
        }


}

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