# Can't go further Diff Two Arrays

Can't go further Diff Two Arrays
0

#1

Tell us what’s happening:

``````function diffArray(arr1, arr2) {
var newArr = [];

// Same, same; but different.
//   for(var i = arr1[i]; i <= arr1.length - 1; i++) {

//     for(var j = arr2[j]; j <= arr2.length - 1;j++ ) {
//        arr1[i] == arr2[j] ? "next" : newArr.push(arr1[i]);
//     }

//   }

for (var i =0; i <= arr2.length - 1;i++) {
arr1[0].indexOf(arr2[i]) > -1 || arr2.indexOf(arr1[i]) newArr.push(arr1[i]) : newArr.push(arr2[i]);

}

return newArr;
}

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

Your Browser User Agent is: `Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36`.

#2

Let me start by asking what you think the above line code should be doing, then we will attempt to address why you are getting the following error in your console:

SyntaxError: Unexpected token, expected ;

#3

let me explain in this code, this one a little bit correct one ;

``````  var newArr = [];

for (var i =0; i <= arr2.length - 1;i++) {
if(arr1[0].indexOf(arr2[i])>-1) {
//here I want to check if arr1 is equal to arr2, if not will give array
return newArr.push(arr2[i]);

}if else( arr2[0].indexOf(arr1[i])>-1) {

return newArr.push(arr1[i]);

}

}

return newArr;
}

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