Algorithms - Find the Symmetric Difference

Tell us what’s happening:
The starter code is:

function sym(args){
return args

sym([1,2,3], [5,2,1,4])

I’m not sure how to access the second array(or subsequent arrays, for that matter), if there is only one argument in the function declaration. When I console.log args.length, the response is ‘3’. How do I access the properties of other elements?

It seems like a relatively easy problem, so I’m sure I’m overlooking something simple, or making it harder than it really is.

  **Your code so far**
function sym(args) {
return args;

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

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Algorithms - Find the Symmetric Difference

Link to the challenge:

1 Like

The link you posted includes: function func1(a, b, c) {
// expected output: 1

// expected output: 2

// expected output: 3

func1(1, 2, 3);

but in the function declaration, there are 3 parameters. In the function declaration for this challenge, there is only one, and subsequent tests will include more than that.

function sym(args) {

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

This returns ‘2’.

Oh I get it. ‘arguments’ is a new one for me. Thanks for your help!

1 Like

you can also change the function signature, and use the rest operator :person_shrugging: