I’m not sure why this won’t work.
Your code so far
function diffArray(arr1, arr2) {
var newArr = [];
// Same, same; but different.
var arr = arr1.concat(arr2);
for(var i = 0; i < arr.length; i++){
if(arr.indexOf(arr[i]) == -1){
newArr.push(arr[i]);
}
}
return newArr;
}
diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/diff-two-arrays