Find the Symmetric Difference (input arguments?)

Find the Symmetric Difference (input arguments?)
0

#1

Tell us what’s happening:
Sorry I’m new to this and trying to complete some of the Coding Interview Challenges.

This problem is suppose to take in args which is an array of arrays. However when I console.log(args) it only gives an array. What am I missing here?

Your code so far

function sym(args) {
  console.log('START HERE')
  console.log(args)
  

  return args;
}


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0.

Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/algorithms/find-the-symmetric-difference/


#2

Where did you read in the instructions that an array of arrays would be passed into the function? Try reading the instructions again to see what will actually be passed into the function.


#3

Try searching for “javascript arguments object”. It will be very clear once you read it.


#4

Sorry I didn’t mean array of arrays. What I meant was args[0] would extract the first argument and args[1] would extract the second argument.


#5

Nope. args as you have it written in your function declaration is the first argument and only the first argument.

function sym(args) {
  console.log('START HERE')
  console.log(args)
  return args;
}

sym([1, 2, 3], [4, 5, 6], [7, 8, 9]);  //displays [1, 2, 3]

args[0] would be 1 and args[1] would be 2, because those are the first two elements of the array referenced by args.

It seems you may want to review the lesson in the previous JavaScript sections before tackling these advanced algorithm challenges.


#6

would extract number 1 from first array.
args[1] number 2, args[2] would number 3, args[2] would go out of bound and so on …
arg can catch only first array’s members. As i said before, arguments object javascript.
Hell, try console.log(arguments[1]) see what happens. You’ll get second array. Problem is that you don’t know in advance how many array will be passed as arguments. So iterate over “arguments”. and print’em just to see. Use for loop for which as a second parameter you’ll use length of “arguments” arguments.length


#7

thank you this was all I was looking for.

clearly not familiar with javascript but args (which is plural) is confusing.

read up on the arguments object in javascript. thanks again