Cuéntanos qué está pasando:
Hi!.
Why this code doesn’t work well with the property .hasOwnProperty()
at the third argument[0]
is the problem, just works well from 1 to 4, apart from there doesn’t work.
**Tu código hasta el momento**
function uniteUnique(arr) {
let args = [];
let newArr = [];
for (let i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
args.map(x => {
x.map(z => {
if(!newArr.hasOwnProperty(z)){
newArr.push(z);
}
})
})
console.log(newArr)
return newArr;
}
uniteUnique([1, 2, 3], [5, 2, 1, 4], [5, 1], [6, 7, 8]);
Enlaza al desafío: