you are passing two arguments to the function
argument[0] = [1, 2, 3]
argument[1] =[5, 2, 1, 4]
so
function sym() {
for(var i=0; i<arguments.length; i++){
arguments[i].forEach(function(elem){console.log(elem)});
}
will log
1
2
3
5
2
1
4
I think i understand what im doing wrong, but unfortunately i have no idea how to solve this problem.
i thought there unspecified number of arrays but one of the hint answers seems to use only two.
at one point i was getting mostly correct using something like this
lets get started on the right foot
The instructions say …
Create a function that takes two or more arrays
according to the instructions
you find the dif between the first two arrays
then you must retain that result
if there is no third array then
just return the stored result
if there is a third array then
you must find the difference between the third
array the stored result
then store the new result
if there is no fourth array then
just return the stored result
if there is a fourth array then
you find the difference between the fourth
array and the stored array
and so on
so lets start like this
First
function sym() {
var dif = [...new Set(arguments[0].slice())];
var arg;
here we are making a NewArray populated
by the first argument with any duplicate
values removed
dif will be the storage array
arg will be used for convenience
now we must get the second array
and any other arrays that might be
in arguments
the for loop starts with i=1 because
we already have arguments[0]
arg is used to point to the array we are
currently working with that will be
compared to the stored array
Yes i was just thinking about it wrong. There is no need to compare each array with every other array directly just compare the difs of any two until the unique ones of every pair have been diffed.
please read my post again
i have added to it
if you like I can continue
all the way thru my own
working solution
please post here if
you wish me to continue
thats the best concise way to do. the biggest thing i was missing was = [...new Set(arguments[i]]
for reasons it doesnt let you operate on argument itself
is it a mutable issue