Not accepting solution although it works

Tell us what’s happening:
Describe your issue in detail here.
Hi, my solution is being rejected but I used console.log to confirm the solution. The error says:
" // running tests
findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; }) should return undefined .
// tests completed"

So I used the function data from that error in a console.log to run through my code and it returns ‘undefined’ like expected. Not sure why it won’t accept it.

  **Your code so far**

function findElement(arr, func) {
for (let i=0; i<arr.length; i++){
  if(func(arr[i])) {
    return arr[i];
} return "undefined";

console.log(findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; }));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.109 Safari/537.36

Challenge: Finders Keepers

Link to the challenge:

"undefined" !== undefined

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.