Finders Keepers using filter

Tell us what’s happening:

Why isn’t my program working?

Your code so far


function findElement(arr, func) {
  let funcArr = arr.filter(func);
  let result = funcArr.slice(0, 1).join('');
  if (funcArr == '') {
    result = undefined;
  }
  return result;
}

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/finders-keepers/

You are returning a string, not a number
You may want to not use join() and instead find an other way

There is a simple way with which you don’t even need to use the if statement