# Symmetric Difference.. can't debug my solution :(

Symmetric Difference.. can't debug my solution :(
0

#1

Hello! I feel like I’m near but this code works over 2 and 3 arrays… seems not to compare with a 4rt given array. After hours and 2 complete different version I think I need help… I think there is some problem with the for loop but…

``````//this function just extract the argument and create an array with them
function sym(args) {
var newArr = [];
for (var key in arguments) {
newArr.push(arguments[key]);
}

var a=newArr[0];
var b=newArr[1];
var c=[];

loop(a,b,c);
function loop(a,b,c){

//test first array over the second array of loop function
for(i=0;i<a.length;i++){
if(!b.includes(a[i]) && !c.includes(a[i])){
c.push(a[i]);
}
}

//test second array over the first array of loop function
for(i=0;i<b.length;i++){
if(!a.includes(b[i]) && !c.includes(b[i])){
c.push(b[i]);
}
}

}

// call the function loop to test the result array over the next one
for (var i=2;i<newArr.length;i++){
a=c;
b=newArr[i];
c=[];
loop(a,b,c);

}

return c;

}``````