FCC Pedagogical Problem with "'Diff Two Arrays"

Tell us what’s happening:

Hi,

I was stuck on this exercice and I looked the Basic solution. I was suprised to see that there was no use of .slice method, neither, .filter and only .indexof.

Why did FCC offer a solution that doesn’t include any of the recommended functions in the exercice page?

I am looking for a solution with the use of .slice, .indexOf, .filter and .concat.

Your code so far


**Your browser information:**

Your Browser User Agent is: ```Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0```.

**Link to the challenge:**
https://www.freecodecamp.org/challenges/diff-two-arrays

I actually did it using only 3 of those, I didn’t use slice

I can’t exactly say it’s the best way

function diffArray(arr1, arr2) {
 const notInArr1 = (c) => arr1.indexOf(c) === -1;
 const notInArr2 = (c) => arr2.indexOf(c) === -1;

 const left = arr1.filter(notInArr2);
 const right = arr2.filter(notInArr1);
 return left.concat(right);
}

If you’re wondering about const and the weird => notation, it’s a more modern feature of javascript, you can read notInArr1 as a function that takes in some c and outputs what’s on the right hand side of the arrow.

const and let are newer (and superior imo) alternatives to var that have different scoping rules and consts can’t be reassigned