Tell us what’s happening:
Guys i can’t figure out what’s wrong with my code. Would really appreciate if someone could help me out …
Your code so far
function diffArray(arr1, arr2) {
var newArr = [];
for(var i =0;i<arr1.length;i++){
for(var j=0; j<arr2.length;j++){
if(arr1.indexOf(i)===arr2.indexOf(j))
{
arr1.splice(i,1);
arr2.splice(j,1);
}
}
}
newArr = arr2.concat(arr1);
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/60.0.3112.101 Safari/537.36
.
Link to the challenge: