Hi everyone,
I always write my code in Atom because I find it more comfortable to work there are then copy/paste everything into the FCC editor. My solution for Finders Keepers works wonderfully on my locally saved files but doesn’t work in FCC, even though the console is giving me no error and logging expected results. The only quirk is that it’s giving me the first result (2) twice on the FCC page (not on my file).
Does anyone know how to fix this? Unless there’s something wrong with my code that I’m not seeing Thanks!!
function findElement(arr, func) {
var newArr = [];
newArr.push(arr.filter(func));
var num = newArr.join("").substr(0,1);
console.log(num);
return num;
}
findElement([1, 2, 3, 4], function(num){ return num % 2 === 0; });
findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; });
findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; });