Diff Two Arrays - unexpected results, and seeing console output

Tell us what’s happening:
It looks like the code I’ve written returns an array of arrays instead of a single array with the right results. The matches look correct, but I’m missing something about how I’m handling the data.

Your code so far

function diffArray(arr1, arr2) {
  var newArr = [];
  // Same, same; but different.
  // Check for each index of array on the other one. 
  // Result of indexOf being -1 means it is not included, this added to newArr.
  newArr.push(arr1.filter( x => arr2.indexOf(x) < 0));
  newArr.push(arr2.filter( x => arr1.indexOf(x) < 0));
  return newArr;

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);

I also tried writing:

  newArr += arr1.filter( x => arr2.indexOf(x) < 0);
  newArr += arr2.filter( x => arr1.indexOf(x) < 0);

That resulted in passing different tests and failing ones the original code passed.

Also, is there a way to see the console output for the multiple tests FCC runs? I have been copying my code into repl.it, then copying several console.log() statements with the tests in order to see what my code does. Is there an easier way?

Link to the challenge:

You can see the output of the different tests if you add console.log(newArr) before the return statement, then open the browser console, clean it and Run the tests

You are almost there, just a little tweak…
Remember that filter() returns an array, so you are pushing arrays to newArr

Looks like adding the spread operator will add the results of the array instead of additional arrays. I.e.

  newArr.push(...arr1.filter( x => arr2.indexOf(x) < 0));
  newArr.push(...arr2.filter( x => arr1.indexOf(x) < 0));