Hi. I had a question about why the spread operator [...arr]
can’t be used in place of [...arguments]
.
Here is the code that I originally had that didn’t work because I used [...arr]
instead of [...arguments]
.
function uniteUnique(arr) {
let newArr = [];
let fullArr = [...arr];
console.log(newArr);
for (let i = 0; i < fullArr.length; i++) {
for (let j = 0; j < fullArr[i].length; j++) {
if (newArr.indexOf(fullArr[i][j]) === -1) {
newArr.push(fullArr[i][j]);
}
}
}
return newArr;
}
uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);