unction uniteUnique(arr) {
let final =[];
let arrg = [...arguments];
arrg.forEach(ele =>{ele.forEach(ele1=>{if(final.indexOf(ele1)<0){ final.push(ele1)}})});
return final;
}
uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
What is your question?
I would guess you are asking why it is not working?
Console log your args
(console.log(args)
)after you create it and look at the browser console
Is this what you need?
function uniteUnique() {
const args = [...arguments];
const uniqueArgs = [];
args.forEach(arr => uniqueArgs.push(...arr));
return [...(new Set(uniqueArgs))];
}
uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
// [1, 3, 2, 5, 4]