Need Help with symmetric Difference[Solved]

Hi,

I was really struggling with - https://www.freecodecamp.org/challenges/symmetric-difference , so looked at the hints, had a hard time understanding those hints , searched again at forum and found people using foreach, then had a hard time understanding foreach :slight_smile: , now i am stuck at being able to use foreach for just 2 values, and have no idea making it work for all loops, i can make them all store in an argument like here -

var  test = [];
  
    for(var i = 0; i < arguments.length; i++){
        test.push(arguments[i]);
    }

But how do i make it run for all - my code below kindly guide -


    function sym(arg1,arg2){
        var test1 = [];
        var x;
        arg1.forEach(function(x){
           if(arg2.indexOf(x) < 0 && test1.indexOf(x) < 0){
               test1.push(x);
           } 
        });
        
        arg2.forEach(function(y){
           if(arg1.indexOf(y) < 0 && test1.indexOf(y) < 0){
               test1.push(y);
           } 
        });
        
       return test1;
        
    }
sym([1, 2, 3], [5, 2, 1, 4]);

Ok i got it just went through reduce…