Algorithms - Find the Symmetric Difference

Tell us what’s happening:
Describe your issue in detail here.
Can somebody explain why the test comparing elements in the second array passed into this function as args, if ((arguments[1][i] in arguments[0]) === false),
works by adding [5, 4] to symDif1 while the other test , ((arguments[0][i] in arguments[1]) === false) creates an empty array ? The contents of both arguments[0] and arguments[1] are identical for both if statements, but the comparison of the first array to the second produces an empty array instead of [3] as expected.

  **Your code so far**
function sym(args) {
console.log(arguments[0], arguments[1]);

let symDif1 = [];
for (let i = 0; i < arguments[1].length; i++) {
  if ((arguments[1][i] in arguments[0]) === false) {

console.log(arguments[0], arguments[1]);

let symDif2 = [];
for (let i = 0;  i < arguments[0].length;  i++) {
  if ((arguments[0][i] in arguments[1]) === false) {

return args;

sym([1, 2, 3], [5, 2, 1, 4]);
  **Your browser information:**

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

Challenge: Algorithms - Find the Symmetric Difference

Link to the challenge:

The in operator is not working like you think it is. It is checking if the index is in the array.

There are much better array methods you could have chosen for this task. The first that comes to mind is the includes method.

Its bugged because the in keyword checks if the index is in the array, not the value. Try it out like this:
console.log(3 in [5, 2, 1, 4]); //returns true because the array has index from 0 - 3
console.log(4 in [5, 2, 1, 4]); //returns false because the array has index from 0 - 3

Got it. Thanks. I was going to switch to includes() but I wanted to understand what was happening with in first. I think I was confusing it with using in in a Python for statement.