Diff Two Arrays javaScript unable to pass some test case

Tell us what’s happening:

Your code so far


function diffArray(arr1, arr2) {
  var a = [],diff=[];
for(var i=0;i<arr1.length;i++){
  a[arr1[i]]=true;
  }
  for(var i=0;i<arr2.length;i++){
if(a[arr2[i]]){
  delete a[arr2[i]];
}
else
{ a[arr2[i]]=true;
  }
  }
  for(var k in a) {
diff.push(k);
  } 
  return diff; 
}

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/72.0.3626.119 Safari/537.36.

Link to the challenge:

Hi,

I think there might be a bug in the exercise. I tried a couple different solutions in the fcc console and they failed, but passed in the IDE I was using.

Your code worked, by the way.

You are returning ["4"], strings, I am pretty sure the challenge wants you to return numbers

@JP-Dub could you have a similar issue?

Haha. While that isn’t the issue I was having last night while trying to help Gunjan, it did make me realize the solution I had, both of them were wrong. I fixed my code though. Strange to me that I would have seen those pass in my IDE, because today they failed. SMH.

1 Like

Is it ? somehow i manage to clear it having a tough day … :joy::joy: