Tell us what’s happening:
Can someone tell me why my array doesn’t concat?
Your code so far
function uniteUnique(arr) {
let args=Array.prototype.slice.call(arguments);
var i=0;
var b=arguments.length;
var a=[];
for(let i=0;i<b;i++){
a=arguments[0].concat(arguments[i]);
}
console.log(a);
for(let i=0;i<a.length;i++){
for(let j=1;j<a.length;j++){
if(a[i]===a[j] && i!==j){
a.splice(j,1);
}
}
}
console.log(a);
return a;
}
uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36
.
Challenge: Sorted Union
Link to the challenge: