# Sorted Union I try I dont how to

Tell us what’s happening:
This is very hard task use only reduce.
how can that be? I study, but accumulator just take number and get in. No arrays.

I have no idea try concat

``````       var i =0;
return arr.sort().reduce((a, currentValue) => {
// console.log(currentValue);
const length = a.length;

if (length === 0 || a[length - 1] !== currentValue) {
arguments[i]=currentValue;i++;
}

return arguments ;
});
}
uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);

return arr.reduce(function(accumulator, currentValue) {
return accumulator.concat(currentValue);
},
[]
)
in these indexof is not a function even that mozzila is from example
return  arr.reduce(function(elem, cuv, num,duplicatesArray) {
//console.log(duplicatesArray)
if(   duplicatesArray.indexOf(num) == -1)
arr.remove(cuv) ;
});       arg

{
``````

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

https://www.freecodecamp.org/challenges/sorted-union
I figured out with HINT and I am pissed off.
its becasuse arr is not array I did not notice the are only one .

You do not have to use reduce. You can solve the challenge any way you like. Once you figure it out on your on, let me know and I will post my blurred out solution using reduce.

Arguments object

``````Array.prototype.reduce()!
``````

I figured out with HINT and I am pissed off this task, because with filter I know it, but that say is lesson to reduce
its because arr is not array I did not notice the are only one [].
I am only one who really use the FC task by task. An I hate mozzilla help JS, is so stupid to understand english like that. Nobody can tell if you want return the accumulator as array you must put the , [] because the push didn’t work ?
I loose one day to this solutions because, programators are not capable use words.
function uniteUnique(arr) {

How can I know you point of arguments arefrom uniteUnique. I was thinking use the arguments i n loop reduce.
var args =Array.from(arguments);
var d = args.reduce(function(accumulator, currentValue) {
return accumulator.concat(currentValue);

``````  }, []
)
``````

var newarr =[];
return d.reduce((accumulator, currentValue,currentIndex, array) => {
console.log(currentValue + “”+ currentIndex);
const length = accumulator.length;
if(! accumulator.includes(currentValue)) {
accumulator.push(currentValue);

}

``````return accumulator ;
``````

}, []);

}

Again, the challenge does not require you to use reduce. It just provides some helpful hints of things you could use.

But Yes because if not use the reduce you on next lessons lost. and there is no helpfull link. I look In the mozzila ah… arguments is like array. who write these manuals? He must really live in other world. If I have time I completely rewrite these manuals even I am beginner.

Since it seems you figured it out, I will post my solution which uses reduce and filter.

``````function uniteUnique(...arrays) {
return arrays.reduce((all,arr)=>all.concat(arr.filter(val=>!all.includes(val))));
}
``````

It will be nice if one lessons beforeshow …arguments is not because of lazy writer, but the has meanning.
I have writing in VB and there wasn’t something undreadable like that. Who created that? The first rule is readable code. If you back after five year I guarantee you didn’t know what three dots means. The JS is full of these amaters solution. Every stupid function has own triggers.

The rest parameter syntax (used in with …arrays in my code above ) is a newer syntax as of ES6 and accomplishes the same thing as:

``````var arrays = Array.prototype.slice.call(arguments);
``````

OR

``````var arrays = [].slice.call(arguments);
``````

OR

``````var arrays =Array.from(arguments);
``````

You will find in JavaScript, there are multiple ways of doing the same thing. Browsers must support the older ways, so that legacy code can still work. The more you study JavaScript and study others’ code, you will see many variants of code which do the same thing.

Its not about the variabilites. In Britain traffic cars goes left, always. The some Principe if you are in Southampton or London. The same principle, same for example i++ is everywhere. Imagine in one function it will i+ in second Iplus in third iI. in one var in second dim in third alias in for \$ in five nick . If we don’t like the system F() use … everywhere, but no mixing two because someone want to be special. If some one want that he could make new JSAlternative, because they screw up the language with own sign.
in our country missing 20000 IT-people . and I yesterday make an change in mozzila sites and guess what to explain … and these people erase that, because they want to be special, only one. I recommend the book how google works from larry page. The sign of autor cannot be visibile. That is hardest thing on the world. The boolean alias by mathematician Boolean is enough. I do no want that call boolean, that must be a universalistic princip. I think the IF and For. what if some day call function by some dictator?