Build a Symmetric Difference Function - Build a Symmetric Difference Function

Tell us what’s happening:

I tested all of the steps offered and got the same return output as the supposed outputs. I am a little confused as to what is causing the lesson from completing since it is returning the correct outputs.

Your code so far

function diffArray(array1, array2) {
  let filtered = array1.filter((thing) => array2.indexOf(thing) !== -1);

  let final = [...array1, ...array2];
  for(let i = 0; i<filtered.length;i++){
    while(final.indexOf(filtered[i])!==-1){
      final.splice(final.indexOf(filtered[i]), 1);
    }

  }
  return filtered;
}


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 OPR/134.0.0.0

Challenge Information:

Build a Symmetric Difference Function - Build a Symmetric Difference Function

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-symmetric-difference/68ad9821ee41baad9cb0fd4e.md at main · freeCodeCamp/freeCodeCamp · GitHub

Hi @gladennn,

How are you testing?

Your first failing test is not returning the correct output:

console.log(diffArray(["diorite", "andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]))

Happy coding

I double checked the console logs i realized it was a variable naming issue and i forgot to change the return value. Thank you so much!