Diff two arrays!

Tell us what’s happening:
cannot return more than one unmatching element :frowning:

Your code so far


function diffArray(arr1, arr2) {
    var newArr = [];
     // let checkers= (item)=>{
       // let result=arr2.filter((element)=>{element==item});
         // console.log(result);

    if(arr1.length>arr2.length)
    { let ff= arr1.filter(element => { return !arr2.includes(element)});
         return(ff);
    }
    else{
        let ff= arr2.filter(element => { return !arr1.includes(element)});
         return(ff);
    }      
} 

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays

Your algorithm is wrong. You should check both arrays, but currently you’re returning after checking only one of the arrays.

1 Like

Thank you so much for your insight!! Solved it ! :smiley: