Diff Two Arrays using concat and filter methods

Tell us what’s happening:
I’ve used the concat method to join both of the arrays. I’m planning on using filter to return true only if the value is unique and return false when the value is duplicated within the array. I can’t seem to figure out how to do that though. any ideas would help.

Your code so far


function diffArray(arr1, arr2) {
  var newArr = [];
  return arr1.concat(arr2).fiter(value=> )
  
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);

Your browser information:

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

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

That was such great hint however, I am getting a arr1.concat… .filter isn’t a function error. Do you know why and does my logic check out?

function diffArray(arr1, arr2) {
var newArr = ;
// Same, same; but different.
return arr1.concat(arr2).fiter(function(value){
if(arr1.includes(value)&&arr2.includes(value))
{return false;}
else {
return value;
}
});
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);

Because you have a typo on this line.

1 Like

Thanks so much for your help and patience