Diff Two Arrays..3

Diff Two Arrays..3
0

#1

Could someone help with that, what is wrong with my code?

Your code so far


function diffArray(arr1, arr2) {
  var newArr = [];
  // Same, same; but different.
  var newa = arr1.concat(arr2);
var fil;
  for(let i = 0;i<newa.length;i++){
    if((arr1.indexOf(newa[i])===-1&&arr2.indexOf(newa[i])>=0)||(arr1.indexOf(newa[i])>=0&&arr2.indexOf(newa[i])===-1)){
      newArr.push(i);
    }
    
  }

  return newArr;
}

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays


#2

Do you have a more specific question about a specific par t of your code?

Do you understand what your function is returning for the tests you are failing?


#3

Hint: The problem is what you are pushing into newArr. You are so close though.


#4

AHHHHHHH , YES thank you man , i realized it.what a mistake