Tell us what’s happening:
This code works, but I would like to improve it and make simpler. Does anyone have better solutions?
Your code so far
function diffArray(arr1, arr2) {
var newArr = arr1.filter(a => !arr2.includes(a));
var newestArr = arr2.filter(b => !arr1.includes(b));
return newArr.concat(newestArr);
}
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/68.0.3440.106 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays